Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 7:00PM GMT+8 time zone: Question
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 7:00PM GMT+8 time zone:
Question 14
Discrete event simulation is to simulate events occurring at discrete time points. Between any two consecutive time points, no event occurs.
- 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.
- 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).
- 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
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