$30
1 Problem Description
The manager of City Bank of India’s Bihta branch wants to develop a program that will help him to find the average waiting time a customer spending at the bank. This information is important for the manager as based on that he will be planning to hire more number of staff for this branch if required.
Currently the branch has two counters that provide various services to the customers who come to the branch. The serviceType that a customer can request are as follows-
• MW: refers to money withdrawal. On an avg, it takes x amount time to perform
• MD: refers to money deposit. On an avg, it takes y amount time to perform
• DD: Issue of demand draft. On an avg, it takes z amount time to perform
The bank can receive the details of every customer who are arriving at the branch using custID, arrivalTime and serviceType from an input file (ip.txt). The bank maintains a single queue and both the counters can serve all type of requests. If the arrival time of multiple customers are same then they will be positioned in the queue based on the order mentioned in the input file. Once a service request is completed then counter can process the next request immediately. We can assume that switching to the next request time is negligible.
Also, once a service request of a customer is fulfilled then it is considered as a finishTime of the customer and it is assumed that at finishTime the corresponding customer leaves the branch immediately. Thus, the time the customer spends at the branch is the difference between the finishTime and arrivalTime.
You need to simulate the aforementioned behavior of the customers at the branch and calculate the finishTime, waitTime of each customers. Also, you need to print the average waiting time considering all the customers in op.txt file.
2 Sample Input Output
Contents of ip.txt should reflect the values of time required for different serviceTypes and the custID, arrivalTime and serviceType for each customer
15 /*indicates x value or time needed for MW*/
10 /*indicates y value or time needed for MD*/
30 /*indicates z value or time needed for DD*/
/*Each of the following entries represent custID, arrivalTime and serviceType*/
101 0 MW 102 0 MD 103 2 MD 104 4 DD 105 10 MD
The program should generate an output file where each entry indicates custID, arrivalTime, finishTime, waitingTime of all customers followed by Average waiting time
Contents of op.txt file
101,0,15,15
102,0,10,10
103,2,20,18
104,4,45,41
105,10,30,20
Average waiting time is 20.8