Question
Implement the event-driven simulation of a bank. A queue of arrival events will represent the line of customers in the bank. Maintain the arrival events
Implement the event-driven simulation of a bank. A queue of arrival events will represent the line of customers in the bank. Maintain the arrival events and departure events in a priority queue, sorted by the time of the event. Use a link-based implementation for the event list. The input is a text ? le of arrival and transaction times. Each line of the ? le contains the arrival time and required transaction time for a customer. The arrival times are ordered by increasing time. Your program must count customers and keep track of their cumulative waiting time. These statistics are suf? cient to compute the average waiting time after the last event has been processed. Display a trace of the events executed and a summary of the computed statistics (the total number of arrivals and average time spent waiting in line).
For this assignment you may (and probably should) use the C++ STL queue and priority_queue
_________________________________
So at a very high level. You are creating a priority queue that has the events. You can have arrival and departure events. This is sorted by the time of arrival or departure (respectively). Because it is a priority queue, every add or delete action forces the built-in functions of the priority queue to sort it on the time of arrival. Priority queues normally sort o the highest (time) but we want it to sort on lowest. As a result you have a mix of arrival and departure events mixed in with each other.
If it is an arrival type of event at the top of the priority queue: Get the value of the top item, then pop it off. If there are no people in the bankline (queue) and the teller is available then process that event. In processing the event, we add a departure event to the priority queue (and it will sort itself), starting at the current time plus the listed transaction time (teller is unavailable for more customers during that transaction. In that departure even we keep track of the original arrival time.
If it is a departure event at the top of the priority queue: Get the value of the top item then pop it off and process the departure. If there are no people in the bankline (queue). Because someone just finished with the teller, the teller is now available for another customer. Look in the bankline (queue) to see if there are any people in the bankline.
When you have a departure event, you have enough information to determine how much the customer waited.
This is c++ language
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started