0% found this document useful (0 votes)
11 views2 pages

Customers in One Queue

The document outlines a simulation involving customers in a queue, detailing how to collect and calculate data on customer service times. It specifies the need to track metrics such as total customers served, average wait time, longest wait time, and the longest queue length. Additionally, it provides an algorithm for processing each minute of the simulation and instructions for writing results to a file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Customers in One Queue

The document outlines a simulation involving customers in a queue, detailing how to collect and calculate data on customer service times. It specifies the need to track metrics such as total customers served, average wait time, longest wait time, and the longest queue length. Additionally, it provides an algorithm for processing each minute of the simulation and instructions for writing results to a file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Customers in One Queue

The diagram shows five customers in a queue. The first customer in the
queue is being served. You are going to run a simulation and collect data C C C C C
about the time it takes to serve these customers.

The driver prompts the user to enter the duration of the simulation. Customers randomly arrive and join the
queue. After the duration is finished, no more customers are allowed in, but all the customers already in the
queue will be served.

After everyone has been served, write these calculations to a file:


 The total number of customers served during the simulation.
 The average time each customer waited to get served, from the time they joined the queue to the time
they got served and departed.
 The longest time that a customer waited.
 The length of the longest queue of customers.

What data do you need to collect?

Algorithm in the serveTheCustomers method


What happens in each minute? What might happen in each minute?

Design the Customer class:


private fields?

constructor?

instance methods?

For each minute, write to a file:


 The minute, starting from 1, who is being served, and the queue of customers.
 When a Customer departs, write that customer’s data and the total time spent by all the customers.

Note that the queue could be empty! You will have to deal with that in your code.

The user entered 15 minutes for the simulation below. The chance of a customer arriving in each minute was
0.3. Each customer, when they arrived, was assigned a random number between 2 and 7 for the time they had
to spend at the front of the queue being served.

minute 1: Serving null. Queue []


minute 2: Serving null. Queue []
minute 3: Serving 4-Customer:3. Queue [4-Customer:3]
minute 4: Serving 3-Customer:3. Queue [3-Customer:3]
minute 5: Serving 2-Customer:3. Queue [2-Customer:3]
minute 6: Serving 1-Customer:3. Queue [1-Customer:3]
Depart 0-Customer:3, wait time was 4 minutes. Total time so far: 4

minute 7: Serving null. Queue []


minute 8: Serving null. Queue []
minute 9: Serving 2-Customer:9. Queue [2-Customer:9]
minute 10: Serving 1-Customer:9. Queue [1-Customer:9]
Depart 0-Customer:9, wait time was 2 minutes. Total time so far: 6

minute 11: Serving 3-Customer:11. Queue [3-Customer:11]


minute 12: Serving 2-Customer:11. Queue [2-Customer:11, 2-Customer:12]
minute 13: Serving 1-Customer:11. Queue [1-Customer:11, 2-Customer:12, 3-Customer:13]
Depart 0-Customer:11, wait time was 3 minutes. Total time so far: 9

minute 14: Serving 2-Customer:12. Queue [2-Customer:12, 3-Customer:13]


minute 15: Serving 1-Customer:12. Queue [1-Customer:12, 3-Customer:13, 5-Customer:15]
Depart 0-Customer:12, wait time was 5 minutes. Total time so far: 14

minute 17: Serving 3-Customer:13. Queue [3-Customer:13, 5-Customer:15]


minute 18: Serving 2-Customer:13. Queue [2-Customer:13, 5-Customer:15]
minute 19: Serving 1-Customer:13. Queue [1-Customer:13, 5-Customer:15]
Depart 0-Customer:13, wait time was 7 minutes. Total time so far: 21

minute 20: Serving 5-Customer:15. Queue [5-Customer:15]


minute 21: Serving 4-Customer:15. Queue [4-Customer:15]
minute 22: Serving 3-Customer:15. Queue [3-Customer:15]
minute 23: Serving 2-Customer:15. Queue [2-Customer:15]
minute 24: Serving 1-Customer:15. Queue [1-Customer:15]
Depart 0-Customer:15, wait time was 10 minutes. Total time so far: 31

minute 25: Serving null. Queue []

Total customers served = 6


Average wait time = 5.1
Longest wait time = 10
Longest queue = 3

Look at the output above. Count for yourself:


1. How many customers were served?
2. How long was the longest queue?
3. Look at, e.g., Customer:13
a. When did Customer:13 join the queue?
b. How long did Customer:13 wait at the front, being served?
c. How long, in total, did Customer:13 wait in the store?
4. The user entered a duration of 15 minutes. What does the simulation do after that?

Hints for passing the autograder’s tests:


Your outfile must be in the right format! The autograder will process your outfile to count your number of
customers, longest wait time, longest queue, and total wait time.
1. Use the given variables and methods, not your own.
2. Start the simulation from minute 1.
3. Outfile the data and calculations in the format exactly as above.

You might also like