Hello everyone,
It has been a while since I last logged on. It has been a while since I really needed any major help in programming. But I am here now and I do need a bit of help.
Let me start off by saying that I have tried to do this on my own. I have been trying for over a week, and I have been banging my head against the wall hard enough that I probably have given myself a concussion or 2.
My homework assignment is to design a java simulation program that makes use of queues. It is meant to simulate a store operating, with arrivals, departures, and a closing time. It makes use of 1 server, who is either idle or busy, and 1 queue.
Requirements for the assignment is as follows:
- One must maintain the queue through the Java collections framework.
- One must have separate methods for each of the three simulation activities (arrival, departure, closing).
- Any customers in the queue when the doors close must be processed.
- One must use random numbers that are exponentially distributed for the times between arrivals of successive customers and for the service time for each customer.
- One must compute and output the average length of time spent in the queue per customer.
- One must thoroughly document the code.
I am fairly certain that I can get the three separate methods working in method form if I can get them working, or at least started, in the rest of the code. Right now, I am just trying to figure out how to make this work. I have been experiencing nothing but brain farts when I start working on this program.
The sample code provided to us:
public class asgnthr
{
public static double expo(double mean)
{
double ran = Math.random();
double ex = -mean * Math.log(ran);
return ex;
}
public static void main(String[] args)
{
double meanInterArrival = 10.2;
double meanService = 1.0;
double clock = 0;
double nextArrival;
double nextDeparture;
double closingTime = 1000;
boolean serverIdle = true;
boolean closed = false;
int customerCount = 0;
double customerWaitTime = 0;
double totalWaitTime = 0;
nextArrival = clock + expo(meanInterArrival);
nextDeparture = 5000;
while (!closed)
{
if (nextArrival < nextDeparture && nextArrival < closingTime)
{
System.out.println("arrival");
clock = nextArrival;
nextArrival = clock + expo(meanInterArrival);
}
else if (nextDeparture < nextArrival && nextDeparture < closingTime)
System.out.println("departure");
else
{
System.out.println("closing");
closed = true;
closingTime = 5000;
}
}
}
}
I am not asking for anyone to provide me with any code at all. Rather, I am asking for some help on where to start. How to approach this assignment. What to do in what order. What I need to add to the sample code. I have had this for over a week and I am just running head long into a wall whenever I try to think about it. With the assignment due late at night this Wednesday, I am really reaching the wire. That is why I am now asking for help.
So, any help I can get will be appreciated. It will certainly be more than I've been able to come up with on my own.