Question: C++ / Queue Please write comments and the correct code. You'll receive multiple thumbs up for the correct solution. A bank has 5 tellers. At

C++ / Queue

Please write comments and the correct code. You'll receive multiple thumbs up for the correct solution.

A bank has 5 tellers. At working hour, customers coming in and doing some transactions with tellers. When custoemrs' number greater than tellers, they need to wait in line (queue). When a teller is available, he/she can service another customer immediately.

Assume the bank opens for 60 minutes. For each minute, the probability of a customer comes is 80%. The transaction time with this customer is between 2 and 8 (random integer). At time zero, there is no customer and all tellers are available.

Update the waiting queue every minute,

At time 60 minutes, what is the average waiting time for all the customers?

Use the function names given below. Implement the functions. You can still define more functions if necessary. Then you need to finish the program according to the question above.

//used for generate random number withind designed range

class randomInteger{

public:

unsigned int operator () (unsigned int range); };

randomInteger randomizer;

class Customer{

protected:

unsigned int arrivalTime;

unsigned int processTime;

public:

//constructors

Customer(int at) : arrivalTime(at), processTime(2 + randomizer (6)){ }

Customer() : arrivalTime(0), processTime(0){ }

//operations

bool done(); //the customer finished

int arrival(); //get the arrival time

}

class Teller{

private:

bool free;

Customer customer;

public:

Teller() { free = true; }

bool isFree(); //see if teller is free to work

void addCustomer(Customer & c); //start servicing customer

void setFree(Customer & c);

};

int main(){

int numberOfTellers = 5;

int numberOfMinutes = 60;

double totalWait = 0;

int numberOfCustomers = 0;

vector < Teller > teller(numberOfTellers);

queue < Customer > line;

//your code follow here

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!