Menu

[solved]-Use Priority Queue Fifo Queue Implement Simulator Simulates Customers Entering Leaving Ban Q39065785

you will use your priority queue and FIFO queue to implement asimulator that simulates customers entering and leaving a bank. Youprogram will take as input: the number of tellers, the number ofcustomers, the arrival time and service time of each customer inseconds. You may use an input file that will look as follows:

numTellers 3 numCustomers 4 Customer1 arrival 25 service 70 Customer2 arrival 40 service 40 Customer3 arrival 60 service 124 Customer4 arrival 75 service 32

In this simplified example, there are three tellers working atthe bank. Customer 1 arrives at time 25. Since there are no othercustomers in the bank, all tellers are free and the customer can beserviced immediately. The customer’s departure time is calculatedas 95 (25+70). Customer 2 arrives at time 40, can be servicedimmediately, and is scheduled for departure at time 80. Customer 3arrives at time 60, can be serviced immediately, and is scheduledfor departure at time 184. Customer 4 arrives at time 75.Unfortunately, all tellers are busy. At time 80, customer 2 leaves,freeing a teller and customer 4 can be serviced. Customer 4’sdeparture time is scheduled as 112 (80+32).

The output of your program will be a list of the waiting timesand wait plus service times for all customers. You can output thisinformation to a file or to standard output. For the previousexample, the output of your program would be the following

Customer2 0 wait service 80 Customer1 0 wait service 95 Customer4 5 wait service 112 Customer3 0 wait service 184 Average waiting time = 1.25

you need to take into consideration the following facts whenpreparing your input file.

  • – There are 7 working hours.

  • – The bank has, on average, 150 customers daily.

  • – Service times are between 2 to 8 minutes.

    Average waiting time = sum of waiting times/number ofcustomers.
    You may use random number generation to generate arriving timesbetween 0 and 25,200 (these are the seconds in 7 working hours) andservice times from 120 to 480 seconds.

    Print your waiting queue and priority queue after everysimulated hour.

Your program must declare two instances of the QueType class.The first will store information about each customer arrival thathas not yet been processed. When your program starts, you shouldopen the input file and read in the customer arrival data (for 150customers). For each arrival, create a QueueItem and insert it intothe queue. You can assume that the data stored in the file will besorted by arrival time.

The second instance of QueueType will store information aboutcustomers waiting in line. In other words, if a customer arrivesand cannot be serviced, that customer’s arrival and serviceinformation is stored in the waiting queue. Remember that ItemTypefor this FIFO queue is Customer!

Your program must also declare an instance of the PriorityQueueto store information about customers currently being serviced. Whena teller is freed, the next customer in the waiting line is removedfrom the waiting line and put into the line of customers beingserviced (PriorityQueue).
The PriorityQueue enqueue function will insert items (customers)into the queue where departure time is considered as the priorityof the inserted item (i.e. an item i has a departure time less thanthe departure times of all items after i in the queue.)

If no customers are waiting, the teller remains unoccupied untilanother customer arrives.

The Customer class:

This class has the data members: customer name(String), Arrival(int), service (int) and wait(int). member functions are: At leastsetters and getters for all data members.

Expert Answer


Answer to you will use your priority queue and FIFO queue to implement a simulator that simulates customers entering and leaving a… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *