<!DOCTYPE html> <html> <body> <script> // // The colors red, blue, and yellow are known as the primary colors because they // cannot be made by mixing other colors. When you mix two primary colors, you // get a secondary color, as shown here: // // When you mix red and blue, you get purple. // When you mix red and yellow, you get orange. // When you mix blue and yellow, you get green. // // Design a program that prompts the user to enter the names of two primary colors // to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the // program should display an error message. Otherwise, the program should display // the name of the secondary color that results. // function findSecondaryColor(color1, color2) { ///////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the previous comment block. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////////////////////////////////////////////// } var color1 = prompt("What is the first primary color you'd like to mix? (red, blue or yellow) "); var color2 = prompt("What is the first second color you'd like to mix? (red, blue or yellow) "); alert(findSecondaryColor(color1, color2)); </script> </body> </html>
In: Computer Science
Part (a) CREATE TWO TABLES IN MICROSOFT ACCESS: (1) A Customer Table which includes the following fields: Customer Name, Customer Address, and Credit Limit. (Note: All customers have a $40,000 credit limit). (2) A Sales Invoice table which includes the following fields: Customer Name, Salesperson, Date of Sale, Invoice Number, Amount of Sale. Part (b): Run the following queries: Query 1: List all sales between 10/20/2014 and 11/20/2014 that were greater than $2,500. Include in your query the customer name, date of sale, invoice number, and amount of sale. List the sales in alphabetical order by customer name. Query 2: List total sales by each salesperson for October and November 2014 in descending order. Include in your query the salesperson name and amount of total sales. Query 3: List the total sales by customer in descending order. Include in your query the customer name, customer address, and amount of total sales per customer. Query 4: List the remaining credit available for each customer. Include in your query the customer name, customer address, credit limit, amount of total sales per customer, and remaining credit available for each customer in descending order of remaining credit available.
In: Computer Science
/** * Chapter 6 * Programming Challenge 1: Area Class * This program demonstrates the Area class. */ public class AreaDemo { public static void main(String[] args) { // Get the area of a circle with a radius of 20.0. System.out.println("The area of a circle with a " + "radius of 20.0 is " + Area.getArea(20.0)); // Get the area of a rectangle with a length of 10 // and a width of 20. System.out.println("The area of a rectangle with a " + "length of 10 and a width of 20 is " + Area.getArea(10, 20)); // Get the area of a cylinder with a radius of 10.0 // and a height of 15.0. System.out.println("The area of a cylinder with a " + "radius of 10.0 and a height" + "of 15.0 is " + Area.getArea(10.0, 15.0)); } }
In: Computer Science
Write an article about *Ethics related to information system security* NO PLAGIARISM PLEASE.
In: Computer Science
<!DOCTYPE html> <html> <body> <script> // // A car's miles-per-gallon (MPG) can be calculated with the following formula: // // MPG=Milesdriven/Gallonsofgasused // // Write a program that asks the user for the number of miles driven and the // gallons of gas used. It should then call a function to calculate and return // the car's MPG and display the result. // function calculateMPG(miles, gas) { ///////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the previous comment block. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////////////////////////////////////////////// } var milesDriven = prompt('How many miles have you driven? '); var gasUsed = prompt('How much gas have you used driving that far? ') alert('You car is getting ' + calculateMPG(milesDriven, gasUsed) + ' MPG.'); </script> </body> </html>
In: Computer Science
Write a class to implement HeadTailListInterface. Instead of using an array, use a List object as your instance data variable. (List (Links to an external site.) from the Java standard library- not ListInterface!). Instantiate the List object to type ArrayList.
Inside the methods of this class, invoke methods on the List object to accomplish the task. Note: some methods might look very simple... this does not mean they are wrong!
There is one difference in how this class will work compared to the other: in this extra credit class, you do not have control over the capacity, so you should not print the capacity in display and the capacity does not have to be exactly doubled in the two add methods.
For full credit:
The class header and instance data will be:
public class ListHeadTailList<T> implements HeadTailListInterface<T> List<T> list; // initialize to type ArrayList<T> in the ListHeadTailList constructor
------------------------------------------------------------------------------------------------------------------------------------------------
/**
* An interface for a list. Entries in a list have positions that
begin with 0.
* Entries can only be removed or added to the beginning and end of
the list.
* Entries can be accessed from any position.
*
* @author Jessica Masters
*/
public interface HeadTailListInterface<T> {
/**
* Adds a new entry to the beginning of the list.
* Entries currently in the list are shifted
down.
* The list size is increased by 1.
*
* @param newEntry The object to be added as a new
entry.
*/
public void addFront(T newEntry);
/**
* Adds a new entry to the end of the list.
* Entries currently in the list are unaffected.
* The list size is increased by 1.
*
* @param newEntry The object to be added as a new
entry.
*/
public void addBack(T newEntry);
/**
* Removes an entry from the beginning of the
list.
* Entries currently in the list are shifted up.
* The list size is decreased by 1.
*
* @return A reference to the removed entry or null if
the list is empty.
*/
public T removeFront();
/**
* Removes an entry from the end of the list.
* Entries currently in the list are unaffected.
* The list size is decreased by 1.
*
* @return A reference to the removed entry or null if
the list is empty.
*/
public T removeBack();
/** Removes all entries from this list. */
public void clear();
/**
* Retrieves the entry at a given position in this
list.
*
* @param givenPosition An integer that indicates the
position of the desired entry.
* @return A reference to the indicated entry or null
if the index is out of bounds.
*/
public T getEntry(int givenPosition);
/**
* Displays the contents of the list to the console, in
order.
*/
public void display();
/**
* Determines the position in the list of a given
entry.
* If the entry appears more than once, the first index
is returned.
*
* @param anEntry the object to search for in the
list.
* @return the first position the entry that was found
or -1 if the object is not found.
*/
public int indexOf(T anEntry);
/**
* Determines the position in the list of a given
entry.
* If the entry appears more than once, the last index
is returned.
*
* @param anEntry the object to search for in the
list.
* @return the last position the entry that was found
or -1 if the object is not found.
*/
public int lastIndexOf(T anEntry);
/**
* Determines whether an entry is in the list.
*
* @param anEntry the object to search for in the
list.
* @return true if the list contains the entry, false
otherwise
*/
public boolean contains(T anEntry);
/**
* Gets the length of this list.
*
* @return The integer number of entries currently in
the list.
*/
public int size();
/**
* Checks whether this list is empty.
*
* @return True if the list is empty, or false if the
list contains one or more elements.
*/
public boolean isEmpty();
}
------------------------------------------------------------------------------------------------------------------------
********TESTING ISEMPTY AND EMPTY DISPLAY Empty is true: true Should display: 0 elements; capacity = 10 0 elements; capacity N/A ********TESTING ADD TO FRONT Should display: 1 elements; capacity = 10 [2] 1 elements; capacity N/A [2] Should display: 3 elements; capacity = 10 [3, 4, 2] 3 elements; capacity N/A [3, 4, 2] Empty is false: false ********TESTING CLEAR Should display: 0 elements; capacity = 10 0 elements; capacity N/A ********TESTING ADD TO BACK Should display: 1 elements; capacity = 10 [7] 1 elements; capacity N/A [7] Should display: 3 elements; capacity = 10 [7, 10, 5] 3 elements; capacity N/A [7, 10, 5] ********TESTING CONTAINS Contains 5 true: true Contains 7 true: true Contains 4 false: false ********TESTING ADD WITH EXPANSION Should display: 32 elements; capacity = 40 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31] 32 elements; capacity N/A [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31] ********TESTING INDEX OF Index of 0 is 0: 0 Index of 31 is 31: 31 Index of -5 is -1: -1 Index of 32 is -1: -1 Index of 3 is 0: 0 Index of 5 is 6: 6 ********TESTING LAST INDEX OF Last index of 0 is 1: 1 Last index of 31 is 32: 32 Last index of -5 is -1: -1 Last index of 35 is -1: -1 Last index of 3 is 4: 4 Last index of 5 is 33: 33 ********TESTING SIZE Size is 34: 34 ********TESTING GET ENTRY Element in position 15 is 14: 14 Element in position 0 is 3: 3 Element in position 39 is null: null Element in position -1 is null: null ********TESTING REMOVES Remove front element 3: 3 Remove back element 5 :5 Remove front element 0: 0 Remove back element 31: 31 Should display: 30 elements; capacity = 40 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] 30 elements; capacity N/A [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] Remove element null: null Remove element null: null Remove element 1: 1 Should display: 0 elements; capacity = 40 0 elements; capacity N/A Remove element 1: 1 Should display: 0 elements; capacity = 40 0 elements; capacity N/A Remove element 1: 1 Should display: 0 elements; capacity = 40 0 elements; capacity N/A Remove element 1: 1 Should display: 0 elements; capacity = 40 0 elements; capacity N/A ********TESTING MIX OF ADDS AND REMOVES Should display: 7 elements; capacity = 40 [5, 4, 3, 2, 3, 8, 9] 7 elements; capacity N/A [5, 4, 3, 2, 3, 8, 9] Should display: 5 elements; capacity = 40 [4, 3, 2, 3, 8] 5 elements; capacity N/A [4, 3, 2, 3, 8] ********TESTING WITH STRINGS Should display: 5 elements; capacity = 5 [You, did, it!, Nice, job!] 5 elements; capacity = 5 [You, did, it!, Nice, job!] Contains "Nice" is true: true Contains "You" is true: true Contains "you" is false: false Index of "it!" is 2: 2 Last index of "it!" is 2: 2
In: Computer Science
PYTHON
Part A. Write a program for salespersons to show discounted prices.
a) Request the salesperson to enter the listed price of a
product
b) Write a function to meet the requirements:
i. The function takes the listed price as a parameter
ii. Print a table which lists discounted prices (10%, 20%, 30%,
40%, and 50% off) (see below)
iii. Note that the printing job needs to be done inside the
function [3 pts]
Part B. Write another program to meet additional
requirements:
c) Request the salesperson to enter 2 inputs: (1) the listed price
& (2) increment of discount rates.
For example: the salesperson can enter 0.05 to indicate a 5%
discount increment.
d) Write a function to meet the requirements:
i. The function takes two parameters: (1) the listed price &
(2) the rate increment
ii. Using a loop, print a table which lists discounted prices, up
to 50% off (see below)
iii. Note that the printing job needs to be done inside the
function
Note: All prices (including listed & discounted) must be presented with 2 decimals and $. For discount rate increment, the smallest possible input is 0.01, i.e., 1%. No need to worry if a rate incremental has 3 decimals or more.
In: Computer Science
Run the following R commends.
set.seed(2019) x = rnorm(100,mean=0, sd=2) y = rnorm(100,mean=0,
sd=20)
[NOTE: Do NOT use built-in functions which can directly solve the
problems.]
(1) Compute the means of values in the vectors x and y,
respectively. Which one is more close to zero? Explain the
reason.
(2) Compute the sample standard deviations of values in the vector
x and y, respectively.
(3) Find the index positions in x and y of the values between -5
and 5, respectively
In: Computer Science
programming with processing
Draw a circle in the top left corner of the screen. make your circle go around a square path continuously.the cycle should
-in a straight line go to the far-right side of the window
-in a straight line go to the bottom of the window
-in a straight line go to the far-left corner of the window
in a straight line go to the top left of the window
-keep repeating the above steps
This process should be repeated until program is terminated
drawing should not go out of the bounds of the window .
i have this so far can't get it to got to the left:
int x = 40, y = 40;
void setup()
{
size(600, 600);
}
void draw()
{
background (200);
ellipse (x, y, 80, 80);
if ((x<560))
{
x=x+xdir;
}
else if(y<560)
{y=y+ydir;
}
else if(x<560)
{
}
}
In: Computer Science
go to w3schools online html editor
• Your Name in Bold
• Your Current College Major, Not in Bold text
• A horizontal line
• Your Favorite Hobby in Italics
• Your Favorite Movie written in Red text ... use any resource you would like (web/textbook/etc) to figure out how to complete this step.
• A picture from another website of your Favorite Book or Magazine
• Text under the Book or Magazine stating what it is or why it's your favorite
• A link to an interesting webpage, the link text must match the page you are linking to. (ie: Don't write CNN for the link, and have it point at MSNBC.com)
• A picture of an interesting person that is also a link to their wikipedia page. The picture itself must be the link, no actual text to click on.
• Embed a you tube video of your favorite music video.
In: Computer Science
Java language
This is your first homework on objects and classes, and the basics of object-oriented programming. For each exercise, your task is to first write the class that defines the given object. Compile it and check it for syntax errors. Then write the “demo class” with the main program that creates and uses the object.
a)You are planning to purchase a new motor boat for cool cruises on Porter’s Lake this summer, but you want to simulate it before you make the purchase. Write a class MotorBoat that represents motorboats. A motorboat has attributes for
and the following methods:
Note: If the rate of fuel consumption is r and the distance traveled is d, then the amount of fuel remaining in the tank = fuel in tank – r*d
b) Write a tester program that creates a motorboat with capacity 100 liters, fuel in tank 50 liters, max. speed 100 kmph, rate of fuel consumption 1. Set its speed to 25 kmph and operate it for 30 minutes. Print the current speed, distance driven and the fuel remaining in the tank. Then increase the speed by 25, and operate it for 30 minutes. Print the current speed, distance driven and fuel in tank. Your output should be:
Current speed: 25.0 kmph
Distance driven: 12.5 km
Fuel in tank: 37.5 liters
Current speed: 50.0 kmph
Distance driven: 25.0 km
Fuel in tank: 12.5 liters
Test your program to check for other cases as well.
In: Computer Science
Hello,
I have created the following code in C++. The goal of this code is to read 3 types of employee information(String/*Name*/, String/*Phone number*/,Int/*Office number*/, ) from a .txt file and store that information into an array which can be accessed by various functions. The code below is within a header file, and im trying to define some functions (within a .cpp file) of my class to carry out the following tasks.
I have already managed to define a couple functions, but I'm stuck on the two listed below and need help coding them.
Thank you.
CODE:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
const int SIZE = 25;
struct Phone
{
string employeeName;
string phoneExt;
int officeNumber;
};
class Directory
{
public:
Directory(string/*file name*/, int = SIZE/*max number
of employees*/);
void showPhone(string/*employee phone*/, int
/*employee office*/);
void showPhoneOffice(string/*Name*/) const;
void writeDirectory(ostream &)const;
void addEmployee(string/*Name*/, string/*Phone*/,
int/*Office*/); // this is second function I need help
defining
void showNoEmployees(ostream &) const; //This is
first function I need help defining
int getNoEmployees() const {return noEmployees;}
private:
Phone employees[SIZE];
int maxEmployees;
int noEmployees;
void findEmployee();
};
1. showPhoneOffice() that displays a string(a name) and int( a phone number). The function receives the string and int. It does not return a value. Displays the data or a meaningful error message if the string was not found
2. . addEmployee() that adds an employee(string/*Name*/,string/*Name*/,int/*Office Number*/) to the employee array. The function receives the employee’s string, string and int. It does not return a value. Ensure the employee is not already in an existing array and that the array is not full. You can assume valid data is passed.
In: Computer Science
Blocks/pages are units of both storage allocation and data transfer.
True
False
-------------------------------------
While clustering of records from two or more tables can enhance the performance of some join queries, other queries may see diminished performance.
True
False
----------------------------
databases are too large to fit on the main Memory so they are stored on the magnetic disk
True
False
----------------
In: Computer Science
Cant get this to loop properly. Any tips out there?
import java.util.Scanner;
public class Lab4 {
public static void main(String[] args) {
//Declared variables
int choice;int number; int sum=0; int fact =1;
Scanner scan = new Scanner(System.in);
do {
System.out.println("Please choose one option from the following
menu:");
System.out.println("1) Calculate the sum of integers from 1 to
m");
System.out.println("2) Calculate the factorial of a given
number");
System.out.println("3) Display the leftmost digit of a given
number");
System.out.println("4) Quit");
choice= scan.nextInt();
//Based on choice, the entered menun options will be
executed
switch(choice){
case 1:
System.out.println("enter a number");
number = scan.nextInt();
for(int i =1; i<=number; i++) {
sum = sum + i;
}
System.out.println("the sum of 1 to " + "" + number + " " + "is" +
" " + sum );
number = scan.nextInt();
break;
case 2:
System.out.println("enter a number");
number = scan.nextInt();
for(int i=1; i<=number; i++) {
fact = fact * i;
}System.out.println("The factorial is" + " " + fact);
number = scan.nextInt();
break;
case 3:
System.out.println("Enter Number");
number = scan.nextInt();
while(number >= 10)
number = number / 10;
System.out.println("The left most digit is" + " " + number);
number = scan.nextInt();
break;
default:
System.out.println("Invalid choice.");
number = scan.nextInt();
break;
}
}while(choice!=4); {
}
}
}
In: Computer Science
Write the code in python only.
You will need the graphics library for this assignment. Please download the library and place it in the same file as your solution.
Draw a 12" ruler on the screen. A ruler is basically a rectangular outline with tick marks extending from the top edge. The tick marks should be drawn at each quarter-inch mark. Below the tick marks, your ruler should show large integers at each full-inch position.
In: Computer Science