Can anyone give me suggestions how how they would go about writing the code for this problem. I am not looking for actual code just suggestions and or pseudo code algorithm?
Queue program: Develop a queue class using a linked list representation and use it in a program to simulate a check-out line at a supermarket. Customers arrive in random integer intervals of 1 to x minutes. Also, each customer is serviced in random integer intervals of 1 to x minutes. Request a value for x at the beginning of the run. Run the supermarket simulation for a 12-hour day (720 minutes) using the following algorithm:
Choose a random integer between 1 and x to determine the minute at which the first customer arrives.
At the first customerís arrival time:
Determine customerís service time (random integer from 1 to x)
Begin servicing the customer;
Schedule the arrival time of the next customer (random integer 1 to x added to the current time)
For each minute of the day:
If the next customer arrives,
Enqueue the customer;
Schedule the arrival time of the next customer;
If service was completed for the last customer:
Dequeue the next customer to be serviced;
Determine customerís service completion time;
At the end of the simulation, your program should print out the maximum number of customers in the queue at any one time, and the longest wait any one customer experienced.
My question I guess
I have the Queue Linked List already written but I am clueless on how to write the client file.
thats a lot of stuff youre asking us to write, but you already have the hard part done.
start writing and see what you can come up with... if you run into anything specific, let us know and we'd be glad to help.
some suggestions though:
this may sound a bit obvious, but make a loop and treat each loop cycle as a minute. then, when a customer is serviced, store your service time in an int or something and then count it down each loop cycle until it reaches 0. when it hits 0, the customer is finished and you can dequeue the next one.
also, make a sizeOfQueue() function in your queue class that returns the current size, then run a check in your main program that says
if ( queue.sizeOfQueue() > currentSize )
currentSize = queue.sizeOfQueue();
or you can just have the queue keep up with its max size and then just return it at the end of the function.
So it will loop 720 times so each loop will be a minute but what will be happening in the loop