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
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