Questions
ASSIGNMENT 5 REQUIREMENTS The distance a vehicle travels can be calculated as follows: distance = speed...

ASSIGNMENT 5 REQUIREMENTS

The distance a vehicle travels can be calculated as follows:

distance = speed * time

For example, if a train travels 40 miles per hour for 3 hours,

the distance traveled is 120 miles.

Write a program that asks the user for the speed of a vehicle

(in miles per hour) and how many hours it has traveled.

The program should then use a loop to display the distance the

vehicle has traveled for each hour of that time period.

Here is an example of the output:

What is the speed of the vehicle in mph? 40

How many hours has it traveled? 3

Hour Distance Traveled

--------------------------------

1. 40

2. 80

3. 120

Input Validation:

Do not accept a negative number for speed and

do not accept any value less than 1 for time traveled.

=================================================================

TEST SET

============================

TEST CASE SPEED HOURS

1. 55 12

2. 65 10

3. 75 8

----------------------------

In: Computer Science

Queues are often used to represent lists of things that are being processed according to the...

Queues are often used to represent lists of things that are being processed according to the order in which they arrived -- i.e. "first come, first served".  

Assignment

Write a program that simulates the minute-by-minute operation of a checkout line, such as one you might find in a retail store. Use the following parameters:

1) Customers arrive at the checkout line and stand in line until the cashier is free.

2) When they reach the front of the line, they occupy the cashier for some period of time (referred to as ServiceTime) measured in minutes.

3) After the cashier is free, the next customer is served immediately.

4) Customers arrive at the checkout line at ArrivalRate per minute. Use the function included below (randomChance()) to return the number of customers arriving in a given minute, determined randomly.

5) The line can only hold so many people, MaxLineSize, until new arriving customers get frustrated and leave the store without purchasing anything.

6) ServiceTime is determined at the point the customer reaches the cashier, and should be taken from the random interval MinServiceTime and MaxServiceTime -- use the function randomInt() provided.

7) The overall time of the simulation is SimulationTime, measured in minutes.

The program should take 6 inputs (to be read from a text file named simulation.txt, as numbers only, one per line, in this order):

- SimulationTime - total number of minutes to run the simulation (whole number).

- ArrivalRate - per-minute arrival rate of customers (a floating point number greater than 0 and less than 1). This number is the "percent chance" that a customer will arrive in a given minute. For example, if it is 0.4, there is a 40% chance a customer will arrive in that minute.

- MinServiceTime - the minimum expected service time, in minutes (whole number).

- MaxServiceTime - the maximum expected service time, in minutes (whole number).

- MaxLineSize - the maximum size of the line. If a new customer arrives and the line has this many customers waiting, the new customer leaves the store unserviced.

- IrateCustomerThreshold - nobody enjoys standing in line, right? This represents the number of minutes after which a customer becomes angry waiting in line (a whole number, at least 1). These customers do not leave, they only need to be counted.

At the end of each simulation, the program should output:

- The total number of customers serviced

- The total number of customers who found the line too long and left the store.

- The average time per customer spent in line

- The average number of customers in line

- The number of irate customers (those that had to wait at least IrateCustomerThreshold minutes)

You are free to use any STL templates as needed (queue or vector, for example).

An example input file is posted in this week's Module here.

Example Run

The output should look similar to this:

Simulation Results
------------------
Overall simulation time:     2000
Arrival rate:                 0.1
Minimum service time:           5
Maximum service time:          15
Maximum line size:              5

Customers serviced:           183
Customers leaving:             25
Average time spent in line: 33.86
Average line length:         3.15
Irate customers                10

What to Submit

Submit your .cpp file (source code for your solution) in Canvas.

Random Functions

Use these provided functions for generating your random chance (for a customer arrival) and interval for service times.

bool randomChance(double prob) { 
    double rv = rand() / (double(RAND_MAX) + 1); 
    return (rv < prob); 
} 

int randomInt(int min, int max) { 
    return (rand() % (max - min) + min); 
} 

Before calling these functions be sure to seed the random number generator (you can do this in main()):

srand(time(0));

Outline:

#include <iostream>
#include <queue>

using namespace std;

int main()
{
queue<int> myQ;

// For each test case, do a loop like this:
for (int i = 0; i < SIMULATION_TIME; i++) {
if (randomChance(ARRIVAL_RATE)) {

// Did a customer arrive in this minute?
// If so, put them on the queue
// - Is the queue full? If so, they left.
// If not, continue with rest of the loop

// Checking on the checkout line:
// - Is the current person done?
// - If so, take the next person
// - Get
// - Record how long they waited
// - Generate a random for how long
// they will take at the checkout

// Record various metrics:
// - Average wait time
// - Is the customer irate?
// - Average queue length
// - Increment number of customers serviced
// - How many left because the line was full?

}

// Print a report here

return 0;
}

Test input:

2000
0.10
5
15
5
20
10000
0.05
5
15
5
18
2000
0.20
5
20
10
10
2000
0.20
1
5
10
25
20000
0.50
1
2
50
10

In: Computer Science

3.3 Briefly define the following ciphers: -Caesar cipher -Monoalphabetic cipher -Playfair cipher 3.4 What is steganography?

3.3 Briefly define the following ciphers:

-Caesar cipher

-Monoalphabetic cipher

-Playfair cipher

3.4 What is steganography?

In: Computer Science

Declare a Python list named famfri with the first names of five friends or family members....

Declare a Python list named famfri with the first names of five friends or family members.

Lists and tuples are examples of what kind of Python construct?

Write a Python for loop that prints the names of the friends or family, one per line, without referencing a range or any literal numeric values.


Write Python code examples of statements to remove the name at position 2 from the list in the first problem, and to remove one of the remaining names by referencing that name.

In: Computer Science

A company would like to implement its inventory of smartphones as a doubly linked list, called...

A company would like to implement its inventory of smartphones as a doubly linked list, called

MobileList.

1. Write a Mobile node node class, called MobileNode, to hold the following information about a

smartphone:

• code (as a String)

• brand (as a String)

• model (as a String)

• price (as int)

MobileNode should have constructors and methods (getters, setters, and toString()) to manage

the above information as well as the link to next and previous nodes in the list.

2. Write the MobileList class to hold objects of the class MobileNode. This class should define:

• Two instance variables first and last to keep the reference (address) of the first and last

nodes of the list.

• The MobileList class should implement the following interface:

public interface MList {

public boolean isEmpty();

// returns true if the list is empty, false otherwise

public int size();

// returns the number of items in the list

public MobileNode getNodeAt(int index);

//returns the MobileNode object at the specified index

public void addFirst(MobileNode item);

// adds a Mobile node at the front of the list

public void addLast(MobileNode item);

// adds a Mobile node at the end of the list

public void addAt(int index, MobileNode item);

// adds a Mobile node to the list at the given index

public String removeAt(int index);

// removes the Mobile node from the list that has the given

// index

public String remove(MobileNode item);

// removes the first item in the list whose data equals

// the given item data

public MobileNode[] searchPriceGreaterThan(int p);

//search and return an array of the set of MobileNode items

//having a price greater than p

public double averagePrice();

// return the average price of the mobile nodes in the list

public double averageBrandPrice(String brand);

// return the average price of the mobile nodes in the list

// from the brand given as a parameter (e.g., “Samsung” or

// “samsung”)

@Override

public String toString();

// implement a toString() method that prints the list in the

// format:

//[ size: the_size_of_the_list

// Mobile node1,

// Mobile node2,

//.... ]

}

3. Write a TestMobileList class to test the class MobileList. This class should have a main method

in which you perform the following actions:

• Create a MobileList object,

• Insert 10 MobileNode objects into the created list (from some brands like “Apple”,

“Samsung”, “Huwaei”, “Sony”),

• Print the content of your list,

• Find out in the list the items that have a price greater than 3000. Print them out.

• Remove the first element of the list

• Remove the item at index 3

• Print again the content of your ist,

• Print out the average price of all mobiles in the list

• Print out the average price of all mobiles in the list from “Apple”.

For each operation above, print a small message that describes the operation you are doing.

For example:

System.out.println(“Insertion of 10 Mobile nodes in the list”);

In: Computer Science

Valid or Invalid Password Deliverables • Complete one document that shows your planning (IPO Chart). Include...

Valid or Invalid Password Deliverables

• Complete one document that shows your planning (IPO Chart). Include in it Input, Processing, Output, Variables, Algorithm, Testing Conditions

• Complete the code for your method and test it then upload for grading

Requirements: Write a Java method to check whether a string is a valid password.

Password rules: A password must have at least ten characters.

A password consists of only letters and digits.

A password must contain at least two digits.

Expected Output:

1. A password must have at least eight characters.

2. A password consists of only letters and digits.

3. A password must contain at least two digits Input a password (You are agreeing to the above Terms and Conditions.): abcd1234 Password is valid: abcd1234

In: Computer Science

Language Javascript and HTML Google Treemap Chart is not displaying information and I don't know why....

Language Javascript and HTML

Google Treemap Chart is not displaying information and I don't know why.

Index.html

<html>

<head>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<script type="text/javascript">

google.charts.load('current', {'packages':['treemap']});

google.charts.setOnLoadCallback(drawChart);

function drawChart() {

var data = google.visualization.arrayToDataTable([

['State', 'Region', 'Housing', 'Utilities'],

['Global', null, 0, 0],

['AK', 'Southeast', 150, 167],

['AL', 'Southeast', 79, 99],

['AR', 'Southeast', 83, 92],

['AZ', 'Southwest', 110, 95],

['CA', 'West', 184, 107],

['CO)', 'West', 103, 94],

['CT', 'Northeast', 161, 122],

['DC', 'Northeast', 248, 103],

['DE', 'Northeast', 101, 122],

['FL', 'Southeast', 92, 99],

['GA', 'Southeast', 80, 98],

['HI', 'West', 236, 167],

['IA', 'Midwest', 92, 90],

['ID', 'West', 79, 93],

['IL', 'Midwest', 89, 102],

['IN', 'Midwest', 82, 87],

['KS', 'Midwest', 85, 87],

['KY', 'Southeast', 78, 95],

['LA', 'Southeast', 91, 84],

['MA', 'Northeast', 130, 120],

['MD', 'Northeast', 175, 109],

['ME', 'Northeast', 133, 109],

['MI', 'Midwest', 86, 103],

['MN', 'Midwest', 96, 101],

['MO', 'Midwest', 80, 103],

['MS', 'Southeast', 83, 108],

['MT', 'West', 97, 88],

['NC', 'Southeast', 83, 98],

['ND', 'Midwest', 100, 82]

['NE', 'Midwest', 82, 99]

['NH', 'Northeast', 128, 125]

['NJ', 'Northeast', 166, 135]

['NM', 'Southwest', 97, 92]

['NV', 'West', 87, 84]

['NY', 'Northeast', 188, 117]

['OH', 'Midwest', 83, 97]

['OK', 'Southwest', 80, 93]

['OR', 'West', 117, 99]

['PA', 'Northeast', 98, 109]

['RI', 'Northeast', 132, 124]

['SC', 'Southeast', 83, 107]

['SD', 'Midwest', 98, 94]

['TN', 'Southeast', 78, 89]

['TX', 'Southwest', 83, 96]

['UT', 'West', 82, 85]

['VA', 'Southeast', 93, 97]

['VT', 'Northeast', 138, 128]

['WA', 'West', 102, 85]

['WI', 'Midwest', 91, 104]

['WV', 'Southeast', 86, 100]

['WY', 'West', 117, 95]

]);

tree = new google.visualization.TreeMap(document.getElementById('chart_div'));

tree.draw(data, {

minColor: '#f00',

midColor: '#ddd',

maxColor: '#0d0',

headerHeight: 15,

fontColor: 'black',

showScale: true

});

}

</script>

</head>

<body>

<div id="chart_div" style="width: 900px; height: 500px;"></div>

</body>

</html>

In: Computer Science

Write a function in python that accepts a sentence as the argument and converts each word...

Write a function in python that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY. Please, I want the coding indented and then the results screen shot.

In: Computer Science

Below is an invoice sent out by MegaCorp. Order ID Order Customer Customer Customer Product Product...

Below is an invoice sent out by MegaCorp.

Order ID

Order

Customer

Customer

Customer

Product

Product

Product

Product

Ordered

Date

Num

Name

Address

ID

Description

Finish

Standard Price

Quantity

1006

10/24/2018

2

HugeCorp

Chicago, IL

7

Widgets

Platinum

800

2

8

Widgets

Chrome

790

4

5

Wadgets

Cherry

325

2

4

Scaffolding

Silver

650

1

1007

10/25/2018

6

LittleCorp

Edwardsville, IL

7

Widgets

Platinum

800

1

11

Ladder

Silver

275

3

1008

10/26/2018

2

Huge Corp

Chicago, IL

5

Wadgets

Cherry

325

2

4

Scaffolding

Silver

650

1

STEP 1:

Convert the above to 1NF

  1. Provide a relation of the above INVOICE, underlining the primary keys.

STEP 2:

Consider the following functional dependencies of the invoice data:

OrderID à OrderDate, CustomerNum, CustomerName, CustomerAddress

ProductID à ProductDescription, ProductFinish, ProductStandardPrice

STEP 3:

Convert your 1NF table to 2NF. (i.e., look only at non-key attributes that are dependent on a single PK)

A relation is in 2NF if it contains no partial functional dependencies.

  1. Provide me 2NF relations based on the dependencies above. BE CAREFUL:   I am NOT asking you to do 3NF yet!!

STEP 4:

Now, you’ve realized there are some additional functional dependencies:

CustomerNum à CustomerName, CustomerAddress

Convert your 2NF relations to 3NF based on the dependencies you just received.

In: Computer Science

Explain attacking mechanisms (e.g., step by step procedures or phase by phase: Preparation, Initial Intrusion, Expansion,...

Explain attacking mechanisms (e.g., step by step procedures or phase by phase: Preparation, Initial Intrusion, Expansion, Persistence, Search and Exfiltration, Cleanup) of GhostNet in detail for a given real case (identified by yourself)

(Hints: You should focus on the procedures of the attacking mechanism. Explain the following steps in detail: Preparation, Initial Intrusion, Expansion, Persistence, Search and Exfiltration, Cleanup)

In: Computer Science

my question hasnt been answered yet. So, posting it again. Follow program instructions carefully. spacing is...

my question hasnt been answered yet. So, posting it again.

Follow program instructions carefully. spacing is important.

You are to write a class called Point – this will represent a geometric point in a Cartesian plane (but x and y should be ints).   Point should have the following:

Data:  

  • that hold the x-value and the y-value. They should be ints and must be private.

Constructors:

  • A default constructor that will set the values to (2,-7)
  • A parameterized constructor that will receive 2 ints (x then y) and set the data to what is received.
  • A copy constructor that will receive a Point. If it receives null, then it should

throw new IllegalArgumentException(<”your meaningful String here”>);

If it is OK, the it should initialize the data (of the new instance being created) to be the same as the Point that was received.

Methods:

  • The methods to be implemented are shown in the PointInterface.java. You can look at this file to see the requirements for the methods.
  • Your Point class should be defined like this:

public class Point implements PointInterface

When your Point.java compiles, Java will expect all methods in the interface to be implemented and will give a compiler error if they are missing. The compiler error will read “class Point is not abstract and does not implement method <the missing method>”.

You can actually copy the PointInterface methods definitions into your Point class so it will have the comments and the method headers.   If you do this, be sure to take out the ; in the method headers or you will get a “missing method body” syntax error when compiling…

  • But…a toString() method and a .equals(Object obj) method are automatically inherited from the Object class. So if you do not implement them, Java will find and use the inherited ones – and will not give a compiler error (but the inherited ones will give the wrong results). The Point class should have its own .toString and .equals methods.

Piece of the code:

//This is the interface for a Point class (which will represent a 2-dimensional Point)

public interface PointInterface
{
   // toString
   //       returns a String representing this instance in the form (x,y) (WITHOUT a space after the ,)
   public String toString();

   // distanceTo
   //       throws a new IllegalArgumentException(<your descriptive String> if null is received
   //       returns the distance from this Point to the Point that was received
   //       NOTE: there is a static method in the Math class called hypot can be useful for this method
   public double distanceTo(Point otherPoint);

   //equals - returns true if it is equal to what is received (as an Object)
   public boolean equals(Object obj);

   // inQuadrant
   //           returns true if this Point is in the quadrant specified
   //           throws a new IllegalArgumentException if the quadrant is out of range (not 1-4)
   public boolean inQuadrant(int quadrant);

   // translate
   //       changes this Point's x and y value by the what is received (thus "translating" it)
   //       returns nothing
   public void translate(int xMove, int yMove);

   // onXAxis
   //       returns true if this Point is on the x-axis
   public boolean onXAxis();

   // onYAxis
   //       returns true if this Point is to the on the y-axis
   public boolean onYAxis();

   //=============================================
   //   The method definitions below are commented out and
   //   do NOT have to be implemented
   //   //=============================================

   // halfwayTo
   //       throws a new IllegalArgumentException(<your descriptive String> if null is received
   //       returns a new Point which is halfway to the Point that is received
   //public Point halfwayTo(Point another);

   // slopeTo
   //       throws a new IllegalArgumentException(<your descriptive String> if null is received
   //       returns the slope between this Point and the one that is received.
   // since the slope is (changeInY/changeInX), then first check to see if changeInX is 0
   //           if so, then return Double.POSITIVE_INFINITY; (since the denominator is 0)
   //public double slopeTo(Point anotherPoint)
}

In: Computer Science

When you are developing and implementing a network, one of the primary concerns is controlling and...

When you are developing and implementing a network, one of the primary concerns is controlling and monitoring traffic through the network. How can you effectively utilize a firewall on the network? Also, software vs. hardware - what are the advantages and disadvantages of each?

In: Computer Science

Design a security service that provides data integrity, data confidentiality and nonrepudiation using public-key cryptography in...

Design a security service that provides data integrity, data confidentiality and nonrepudiation using public-key cryptography in a two-party communication system over an insecure channel.

In: Computer Science

DO NOT ANSWER THIS QUESTION[Write a program that the owner of Chica Chic could use to...

DO NOT ANSWER THIS QUESTION[Write a program that the owner of Chica Chic could use to store data about her inventory in a text file. The program should prompt her to input the name, cost price, and quantity of each item of inventory. Each of these three data has to be written to its own line in the file. The program should loop to enable any number of inventory items to be stored and end when the item name is left blank (see Sample Output. User inputs are shown in blue). The program should end by closing the file and printing a file status message. Sample Output Enter the name of the inventory item or ENTER to quit tops Enter the cost price of this item 24.99 Enter the quantity in stock of this item 10 A record was written to file Enter the name of the inventory item or ENTER to quit shorts Enter the cost price of this item 29.95 Enter the quantity in stock of this item 12 A record was written to file Enter the name of the inventory item or ENTER to quit sandals Enter the cost price of this item 19.79 Enter the quantity in stock of this item 8 A record was written to file Enter the name of the inventory item or ENTER to quit The file was created successfully and closed] DO NOT ANSWER THIS QUESTON

Now write another program that reads her inventory file, displays all data for each item, and reports on the inventory value. The cost value of each item and the cost value of the total inventory should be reported. Strive to duplicate the Sample Output below.
Sample Output
Chica Chic Inventory

tops, $24.99 each, 10 in stock, value $249.90
shorts, $29.95 each, 12 in stock, value $359.40
sandals, $19.79 each, 8 in stock, value $158.32
End of file
Total inventory value $767.62

In: Computer Science

Online Store Simulator cpp files needed hpp files provided You will be writing a (rather primitive)...

Online Store Simulator cpp files needed hpp files provided

You will be writing a (rather primitive) online store simulator. It will have three classes: Product, Customer and Store. To make things a little simpler for you, I am supplying you with the three .hpp files. You will write the three implementation files. You should not alter the provided .hpp files.

Here are the .hpp files: Product.hpp, Customer.hpp and Store.hpp three files are below the questions;

Here are descriptions of methods for the three classes:

Product:

A Product object represents a product with an ID code, title, description, price and quantity available.

constructor - takes as parameters five values with which to initialize the Product's idCode, title, description, price, and quantity available

get methods - return the value of the corresponding data member

decreaseQuantity - decreases the quantity available by one

Customer:

A Customer object represents a customer with a name and account ID. Customers must be members of the Store to make a purchase. Premium members get free shipping.

constructor - takes as parameters three values with which to initialize the Customer's name, account ID, and whether the customer is a premium member

get methods - return the value of the corresponding data member

isPremiumMember - returns whether the customer is a premium member

addProductToCart - adds the product ID code to the Customer's cart

emptyCart - empties the Customer's cart

Store:

A Store object represents a store, which has some number of products in its inventory and some number of customers as members.

addProduct - adds a product to the inventory

addMember - adds a customer to the members

getProductFromID - returns product with matching ID. Returns NULL if no matching ID is found.

getMemberFromID - returns customer with matching ID. Returns NULL if no matching ID is found.

productSearch - for every product whose title or description contains the search string, prints out that product's title, ID code, price and description

addProductToMemberCart - If the product isn't found in the inventory, print "Product #[idCode goes here] not found." If the member isn't found in the members, print "Member #[accountID goes here] not found." If both are found and the product is still available, calls the member's addProductToCart method. Otherwise it prints "Sorry, product #[idCode goes here] is currently out of stock." The same product can be added multiple times if the customer wants more than one of something.

checkOut - If the member isn't found in the members, print 'Member #[accountID goes here] not found.' Otherwise prints out the title and price for each product in the cart and decreases the available quantity of that product by 1. If any product has already sold out, then on that line it should print 'Sorry, product #[idCode goes here], "[product name goes here]", is no longer available.' At the bottom it should print out the subtotal for the cart, the shipping cost ($0 for premium members, 7% of the cart cost for normal members), and the final total cost for the cart (subtotal plus shipping). If the cart is empty, it should just print "There are no items in the cart." When the calculations are complete, the member's cart should be emptied.

Here is an example of how the output of the Store::productSearch method might look (searching for "red"):

red blender
ID code: 123
price: $350
sturdy blender perfect for making smoothies and sauces

hot air balloon
ID code: 345
price: $700
fly into the sky in your own balloon - comes in red, blue or chartreuse


Here is an example of how the output of the Store::checkOutMember method might look:

giant robot - $7000
Sorry, product #345, "live goat", is no longer available.
oak and glass coffee table - $250
Subtotal: $7250
Shipping Cost: $0
Total: $7250

In the main method you use for testing, you should only need to #include Store.hpp. Remember that your compile command needs to list all of the .cpp files.

customer.hpp

#ifndef CUSTOMER_HPP
#define CUSTOMER_HPP

#include
#include "Product.hpp"

class Customer
{
private:
std::vector cart;
std::string name;
std::string accountID;
bool premiumMember;
public:
Customer(std::string n, std::string a, bool pm);
std::string getAccountID();
std::vector getCart();
void addProductToCart(std::string);
bool isPremiumMember();
void emptyCart();
};

#endif

product.hpp

#ifndef PRODUCT_HPP
#define PRODUCT_HPP

#include

class Product
{
private:
std::string idCode;
std::string title;
std::string description;
double price;
int quantityAvailable;
public:
Product(std::string id, std::string t, std::string d, double p, int qa);
std::string getIdCode();
std::string getTitle();
std::string getDescription();
double getPrice();
int getQuantityAvailable();
void decreaseQuantity();
};

#endif

store.hpp

#ifndef STORE_HPP
#define STORE_HPP

#include
#include "Customer.hpp"

class Store
{
private:
std::vector inventory;
std::vector members;
public:
void addProduct(Product* p);
void addMember(Customer* c);
Product* getProductFromID(std::string);
Customer* getMemberFromID(std::string);
void productSearch(std::string str);
void addProductToMemberCart(std::string pID, std::string mID);
void checkOutMember(std::string mID);
};

#endif

In: Computer Science