You use a queue to simulate the row of customers through a checkout line in a store. In order to create this simulation, you must model both the passage of time and the row of customers through the line. You can model time using a loop in which each pass corresponds to a set time interval – one minute, for example. You can model the row of customers using a queue in which each element corresponds to a customer in the line.
In order to complete the simulation, you need to know the rate at which customers join the line, as well as the rate at which they are served and leave the line. Suppose the checkout line has the following properties.
Customer s Arriving |
Probabilit y |
0 |
0.3 |
1 |
0.2 |
2 |
0.2 |
3 |
0.1 |
4 |
0.2 |
Initialize the queue to empty.
for ( minute = 0 ; minute < n ; minute++ ) {
If the queue is not empty, then remove the customer at the front of the queue. Compute a random number k. If k is < 0.3, then do not add any customers to the line. If k is < 0.5, then add one customer to the line. If k is < 0.7, then add two customers to the line. If k is < 0.8, then add three customer to the line. Otherwise (if k ≥ 0.8), add four customers to the line.
}
Step 1: Create a program that uses the Java Queue ADT to implement the model described above. Your program should update the following information during each simulated minute, that is, during each pass through the loop:
In order to compute how long a customer waited to be served, you need to store the “minute” that the customer was added to the queue as part of the queue element corresponding to that customer.
S tep 2: Use your program to simulate the row of customers through the line and complete the following table. Note that the average wait is the combined waiting time should be derived from the “combined length of time” calculated in step 1 part b. Take special note that, in this program, the length of the simulation is entered by the user.
D eliverables:
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
Get Free Quote!
293 Experts Online