Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use JAVA program language Discrete event simulation is to simulate events occurring at discrete time points. Between any two consecutive time points, no event

Please use JAVA program language

Discrete event simulation is to simulate events occurring at discrete time points. Between any two consecutive time points, no event occurs.

(a) Write a class Event with two integer instance variable time and type, which represents an event of a specific type occurs at time. Also write the constructor Event(int time, int type), which initializes the attributes using the parameters. In using this class, you can assume the getter and setter methods are available.

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

(c) Write a method waitingTime(int serviceTime) of Bank which returns the average waiting time of the customers whose arrival times are in eventList, where serviceTime is the time each customer being served at the bank counter. In other words, the servicing time of each customer is the same.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions