Question: Write a Java class that implements a discrete event simulator. The simulator should have a method with the following prototype: void simulate(double time), that simulates

Write a Java class that implements a discrete event simulator. The simulator should have a method with the following prototype: void simulate(double time), that simulates the arrival and execution of requests at a generic server for time milliseconds, where time is passed as a parameter to the method. The class should be implemented in its own java file, named simulator.java. The simulator class will internally use a exponentially-distributed random number generator.

Apart from implementing the simulate(...) method, the class should also include a main(...) function. The main(...) function should accept 3 parameters from the calling environment (in the following order):

(a) length of simulation time in milliseconds. This should be passed directly as the time parameter to the simulate(...) function.

(b) average arrival rate of requests, expressed as requests per millisecond;

(c) average service time at the server, expressed in milliseconds; It is responsibility of the main(...) function to internally invoke the implemented simulate(...) function only once.

In this first version, the simulate(...) function will need to print in the console the simulated time at which each request arrives at the system (ARR), initiates service (START), and completes service (DONE).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!