Need Suggestions

This is a discussion on Need Suggestions within the C++ Programming forums, part of the General Programming Boards category; Can anyone give me suggestions how how they would go about writing the code for this problem. I am not ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    84

    Need Suggestions

    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:
    Say so;
    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.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    84

    My question I guess

    I have the Queue Linked List already written but I am clueless on how to write the client file.

  3. #3
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    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.
    I came up with a cool phrase to put down here, but i forgot it...

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    84
    So it will loop 720 times so each loop will be a minute but what will be happening in the loop

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions and question about bool pointers
    By Akkernight in forum C++ Programming
    Replies: 15
    Last Post: 03-22-2009, 01:27 PM
  2. Free Book Suggestions!
    By valaris in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-08-2008, 11:25 AM
  3. Hi, Suggestions on my program please..
    By Siggy in forum C++ Programming
    Replies: 44
    Last Post: 11-23-2004, 10:55 PM
  4. Math Book Suggestions
    By curlious in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-09-2003, 11:43 AM
  5. Learning C for OSX, tutorial suggestions please
    By Nexum in forum C Programming
    Replies: 2
    Last Post: 02-17-2003, 04:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21