**Queues**

**In C++ in Object Oriented Programming**

This program is designed to get you intimately familiar withmanaging a queue … in the form of a bank-teller’s line! You willimplement a queuing system, which in general, consists of servers(tellers) and a queue of objects to be served (customers).

The goal is to compute the *average waittime**– how long a customer waits until histransaction is performed by the bank-teller*. We need to know 4things to simulate a queuing system:

- The number of events (2 in this case – arrivals and departures)and how they affect the system
- The number of servers (start with one and add more for extracredit)
- The distribution of arrival times (for example, a customermight arrive approximately every 5 minutes).
- The expected service time (for example, 6 minutes- you can varythis by transaction type for extra credit)

Note: Changing the values of these parameters will affect theaverage wait time.

To simulate the passing of a unit of time (a minute for example)we increment the clock and run the simulation for a predeterminedamount of time – say 100 minutes i.e. use a loop.

For each value of the clock (say 1-100) the following actionsare processed (loop body):

- If a customer arrives they enter the back of the line (thequeue) and their arrival time is stored.
- If a teller is free and someone is waiting, the customer at thefront of the line moves to the teller and the service time isinitialized (to 6 for example) and the customer’s total wait timecan be determined.
- If a customer is at the teller’s window, the time remaining forthat customer to be serviced is decremented.

Average wait time = total wait time for all customers/totalnumber of customers

**Input:** The number of servers (start with 1),the distribution of arrival times, the expected service time andthe length of the simulation.

Include objects that represent customers (they keep track of howlong they are waiting), tellers( they can be busy or free), theline ( a queue of customers) and timers(tellers decrement theirtimer and customers on line increment their timers).

Use a random number generator to determine the probability of acustomer arriving during each loop iteration: (0.0 – no arrival to1.0 – definitely arrives). For example, if a customer arrives on anaverage of every 5 minutes, the probability is 1 chance in 5 (or.2).

#include <cstdlib>

//rand() returns a value between 0 – RAND_MAX

We want a range of 0.0 – 1.0: float(rand( ))/float(RAND_MAX)

If the random number is between 0 and the arrival probability (.2in our example) then a customer arrives, otherwise no customerarrives.

## Expert Answer

Answer to Queues In C++ in Object Oriented Programming This program is designed to get you intimately familiar with managing a que…