Menu

Please Use Java Program Language Discrete Event Simulation Simulate Events Occurring Discr Q43785211

Please use JAVA program language

Discrete event simulation is to simulate events occurring atdiscrete time points. Between any two consecutive time points, noevent occurs.

(a) Write a class Event with two integer instance variable timeand type, which represents an event of a specific type occurs attime. Also write the constructor Event(int time, int type), whichinitializes the attributes using the parameters. In using thisclass, you can assume the getter and setter methods areavailable.

(b) Write a class Bank with an attribute eventList, which is alist of Event. Add a method generateEvents(int n) which generates nrandom customer arrival events (with event type 0) and put theminto eventList in the order of increasing arrival times. Thearrival time of the first customer is a random integer between 0 to10 (inclusively). Similarly, after the first customer has arrived,the time to wait for the next customer to arrive, the interarrivaltime, is also a random integer between 0 to 10. Other futurecustomer arrivals are similar. For example, if the first customerarrives at 3 and the next 2 interarrival times are 2 and 4, theactual customer arrival times are 3, 5 (=3+2) and 9 (=5+4)

(c) Write a method waitingTime(int serviceTime) of Bank whichreturns the average waiting time of the customers whose arrivaltimes are in eventList, where serviceTime is the time each customerbeing served at the bank counter. In other words, the servicingtime of each customer is the same.

Expert Answer


Answer to Please use JAVA program language Discrete event simulation is to simulate events occurring at discrete time points. Betw…

OR