Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Queue of Service Start with the definition of the Queue class given in the Source Code folder (examples from the textbook 13.21, 13.22, and 13.23)

Queue of Service

Start with the definition of the Queue class given in the Source Code folder (examples from the textbook 13.21, 13.22, and 13.23) and modify (re-write) the Queue class to simulate customer arrivals at the Department of Motor Vehicles) counter.

As customers arrive they are given a ticket number. When a customer service agent is free the customer with the next ticket number is called. This system results in a FIFO queue of customers ordered by ticket number.

Write a program that implements the queue and simulates customers entering and leaving the queue. Input into the queue should be the ticket number and a timestamp when the ticket was entered into the queue. A ticket and its corresponding timestamp are removed when a customer service agent handles the next customer. Your program should save the length of time the last three customers spent waiting in the queue. Every time a ticket is removed from the queue update these times and output the average of the last three customers as an estimate of how long it will take until the next customer is handled.

Sample Output:

The line is empty. Enter '1' to simulate a customer's arrival

or 'q' to quit:

1

Customer 1 entered the queue at time 1447060858.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

1

Customer 2 entered the queue at time 1447060861.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

1

Customer 3 entered the queue at time 1447060866.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

2

Customer 1 is being helped at time 1447060871. Wait time was 13 seconds.

The estimated wait time for customer 2 is 13 seconds.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

1

Customer 4 entered the queue at time 1447060883.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

2

Customer 2 is being helped at time 1447060891. Wait time was 30 seconds.

The estimated wait time for customer 3 is 21 seconds.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

1

Customer 5 entered the queue at time 1447060902.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

2

Customer 3 is being helped at time 1447060906. Wait time was 40 seconds.

The estimated wait time for customer 4 is 27 seconds.

Enter '1' to simulate a customer's arrival, '2' to

simulate helping the next customer, or 'q' to quit:

q

Press any key to continue

Please answer this with C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions