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 c-c++ function that accepts an integer number

Write a C/C++ function that accepts an integer number as parameter and returns a number of which the order of its digits have been reversed.

  Each has a string for their name

Create a class in C++ that holds robot warriors. Each has a string for their name, a number of hitpoints (an float), armor (a defensive modifier(an int)), and weaponry (an offensive multiplier(another int)). You will create 5 robots with a random ..

  Define a class for file that is derived from document

Similarly, define a class for File that is derived from Document and includes a instance variable for the pathname. The textual contents of the file should be stored in the inherited variable text. Redefine the toString method to concatenate all t..

  Represent an instruction supported by simpletron

Implementation contains a Simpletron class and several supporting Instruction classes

  Called cbankaccount

Create a base class, called CBankAccount, and two additional classes (each derived from CBankAccount), called CSavingsAccount and CCheckingAccount.

  T computes and posters the probabilities of two people

Write a C program that computes and posters the probabilities of two people in a group who are born in the same day. The probability of two people being born in the same day of the year, for a group of  n people, is given by the following formula:

  Write a complete c++ program

The main program will read in a parameter value n (read this in main). Then it will call a function read2arrays (details below) to read lists of grades into two arrays, which the main program will call test1 and test2 (or some other names of your ..

  Write a short c++ function

Write a short C++ function, isMultiple, that takes two positive long values, n and m, and returns true if and only if n is a multiple of m, that is, n = mi for some integer i.

  Write an application that creates a quiz

Write an application that creates a quiz, which contains at least 5 questions about a hobby, popular music, astronomy, or any other personal interest. Each question can be multiple choice(a,b,c,d should be user accepted response), or true or false(t ..

  Write a loop that will show the price of silver and gold

Write a loop that will show the price of silver and gold for 1 to 16 ounces in one ounce increments.

  Create a structure that has one variable called value

"Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list.

  Design and implement a c program and structure diagram for

design and implement a c program and structure diagram for the subsequent specification.show writing and calling

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