Generate a random number

Assignment Help C/C++ Programming
Reference no: EM13499404

Overview & Requirements: 

Note: parts of this assignment were inspired by Deitel and Deitel’s Supermarket Simulation problem. We’ve all had the pleasant experience of standing in line at the grocery store. As I’m standing in line I’m always trying to figure out if I chose the line with the fastest service. In most cases, I fail miserably. Let’s write a program to simulate two lines in a grocery store, which will allow us to better understand how to select the fastest line. 

For this assignment you will need to simulate two lines using queues. This will require that you develop enqueue ( ) (insert), dequeue ( ) (delete), and printQueue ( ) operations for a queue. Although you will instantiate two queues, each one of these will consist of the same kind of queue nodes. Define a queue node in the following manner: 

typedef struct queueNode

{

     int customerNumber; // Unique identifier; starts at 1; after 24 hours should be reset to 1

     int serviceTime;   // Random time; varies between express and normal lanes; units in minutes

     int totalTime;     // totalTime = serviceTime + sum of serviceTimes of customers in line before this customer; units in minutes

 

     struct queueNode *pNext;

} QueueNode; 

One of your queues will represent the express lane and the other a normal lane. You will randomly generate arrival times and service times of customers into each lane. The express lane has customers arrive every one to five minutes, and customers arrive every three to eight minutes in the normal lane. Service times vary from one to five minutes, and three to eight minutes, for express and normal lane customers, respectively. As customers arrive into each line print out a message indicating in which line each customer arrives, along with the overall corresponding arrival time and customer number. When customers have finished checking out, print out a message indicating which line the customer was in, along the corresponding customer number and totalTime in the line. Allow for the simulation to run for n number of minutes, where n is inputted by the user. 

The general program flow is as follows:

Generate a random number between 1 – 5 and 3 – 8 for express and normal lanes, respectively. This represents the arrival time of the first customer into each lane. Set the variable for total time elapsed to 0.

As customers arrive into each line, randomly generate a service time for each. Start processing the customers in the lanes based on service time. Randomly generate the arrival time of the next customer into each line. Elapsed time should be updated by one unit.

As each minute elapses, a new customer may arrive and/or another customer may be done checking out. Display the appropriate messages as described above.

For every 10 minutes, print out the entire queue for each line

Repeat steps 2 through 4 for n minutes of simulation. 

Hints: since this is a simulation one minute is really one unit of time. Thus, the incrementing of an integer variable could represent one minute of time elapsing. 

BONUS: 

Modify QueueNode such that it contains a pointer to the start of a dynamic singly linked list. The linked list will consist of grocery items corresponding to one person. These items should be strings like “cereal”, “milk”, “steak”, etc. Adjust the serviceTime of the QueueNode so that it is no longer random, but proportional to the number of items for the person served.

Reference no: EM13499404

Questions Cloud

Operant conditioning is a process of increasing : Operant conditioning is a process of increasing or decreasing a specific behavior through reinforcement (positive or negative), punishment or extinction. The person operates based on the environment through learned discriminative stimulus.
Models of personality would conceptualize : Briefly describe the way in which the following two models of personality would conceptualize, assess and treat an individual who reports an intense fear (i.e. a phobia) of snakes.
You are to write a basic bank application : You are to write a basic bank application, in C++, that allows the user of the application to manually create, modify, and delete bank accounts. Before you write the application you will need to create a class called Account.
What kind of psychology research method : What kind of psychology research method would be used in learning about your personal family health history?
Generate a random number : Generate a random number between 1 – 5 and 3 – 8 for express and normal lanes, respectively. This represents the arrival time of the first customer into each lane. Set the variable for total time elapsed to 0.
Individual psychotherapy : Individual Psychotherapy, describe the basic function and premise of each one on a child’s recovery. Use outside sources to support your answers.
Contributes to healthy-maladaptive psychological functioning : Pick a part of the brain and discribe how it contributes to healthy and maladaptive psychological functioning. Be sure to include examples to support your descriptions.
Write a program to evaluate infix expressions : Write a program to evaluate infix expressions. An infix expression looks like the following:   9 * (5 - 4) + 2 / 6
An assessment of your mental health status : An assessment of your mental health status...are there things you are currently doing that you have found contribute to good mental health? What are things you could add to your personal mental health regimen as a result of content from psychology.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program to find the average value

Write a program to find the average value, the largest value, and the smallest value of a set of numbers supplied as input from the keyboard. The number of values in the data set must be in the range 0 to 20, inclusive.

  Only letters are affected

You are to write a ROT13 (for "rotate 13") decoder to translate a secret message from its encoded state to something readable. In a ROT13 code, 'a' is shifted 13 letters to 'n', 'B' to 'O', 'c' to 'p', 'D' to 'Q', ..., 'N' to 'A', 'o' to 'b', 'P' ..

  How nested if-statements replace with one if-statement

Describe how following nested If-statements could be replaced with one if-statement using logical operator (And/Or/Not). Write down the C++ code example.

  Reads from the external file input.txt

Program that reads from the external file input.txt, counts the letters in every word, replaces the word by that number, and then writes the numbers to an external file output.tx

  Write a program in which set up a douhly-subscripted array

Write a program in which you set up a douhly-subscripted array to store each character in the wit. Ube ;old loops, and the most efficient  statements to do it. Include documentation (comment stmts.) in your program.

  You are the admissions office at abc medical university

You are the Admissions Office at ABC Medical University. You have a large number of applicants for a very few number of available openings at your school. As a result, you need to set some high admission standards. To be accepted, a student ..

  Write a method that accepts a string

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display - "ytivarg". Demonstrate the method in a program that asks the user to input..

  Define and implement structures in c

Define and implement structures in C and summarize the operations of a linked list - Generate a random number between 1 - 5 and 3 - 8 for express and normal lanes, respectively. This represents the arrival time of the first customer into each lane.

  How the function delete can be implemented for arrays

Explain in details how the function Delete() can be implemented for arrays to function exactly as it would with lists. Use pseudo code to clarify your explanation.

  Use the top-down modular approach to design program

Use the top-down modular approach and pseudocode to design a suitable program to solve it. Where appropriate, use defensive programming techniques.

  Dynamic character arrays

Dynamic character arrays str and add contain strings. Write a function append that uses str and add as arguments and appends add to the end of str. Write a main program that illustrates the use of function append to concatenate five strings.

  Generates a random number and asks the user

Write a program in c++ that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd