Write a program that simulates a checkout line at a supermarket. The line is a queue object.

Question:

Write a program that simulates a checkout line at a supermarket. The line is a queue object. Customers (i.e., customer objects) arrive at random integer intervals of from 1 to 4 minutes. Also, each customer is serviced at random integer intervals of from 1 to 4 minutes.

Obviously, the rates need to be balanced. If the average arrival rate is larger than the average service rate, the queue will grow infinitely. Even with “balanced” rates, randomness can still cause long lines. Run the supermarket simulation for a 12-hour day (720 minutes), using the algorithm in Fig. 21.21. Then answer each of the following:

a) What is the maximum number of customers in the queue at any time?

b) What is the longest wait any one customer experiences?

c) What happens if the arrival interval is changed from 1 to 4 minutes to 1 to 3 minutes?

Fig. 21.21

I 2 3 4 5 6 7 8 9 10 II 12 13 14 15 16 17 18 Choose a random integer between 1 and 4 to determine the minute

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java How To Program Late Objects Version

ISBN: 9780136123712

8th Edition

Authors: Paul Deitel, Deitel & Associates

Question Posted: