IUP Computer Science
CO 310 Spring 1993

Assignment #5
(Due   19 April 1993)


    The TEXT file DATA.P5 (in P: on VMS and L:\310\ in Str 107) contains the action commands necessary to simulate the operation of three check-out stations at a supermarket.  Each command occupies one line of the file.  There are three types of commands; each is described below.

1.  The NEW command indicates that another customer is ready to check out.  This customer gets into the check-out line that is the shortest.  If more than one check-out line are equally short, the customer may go into any of the shortest lines.  The NEW command consists of the word NEW, three spaces, and the name of the new customer (no more than 10 characters)

2.  The TAKE command indicates that a cashier takes the next customer from the line at a check-out station.  If there are no customers waiting when the cashier tries to do a TAKE, s/he goes on break (your program must output a message announcing this); the cashier will try to do another TAKE later.  The TAKE command has the word TAKE, two spaces, and the number of the check-out station.  The check-out stations are numbered 1, 2, and 3.

3.  The REPORT command indicates that the current situation must be printed out for each of the check-out stations.  The REPORT command consists of only the word REPORT.  The form for the printout should be as follows

       Status Report
     Station   Served    Waiting
        1         n      namelist
        2         n      namelist
        3         n      namelist

Here, "n" is the number of customers served at each station up to the moment the REPORT command is given and "namelist" is a list of the names of the customers currently waiting at each station, in order. The names should be listed horizontally on one line, with the namelist left blank if there is no one waiting.

 Write a Pascal (VMS or Turbo) program to perform the super market simulation.  Your program must set up 3 queues to simulate the check-out stations.  The program must also read the DATA.P5 commands and perform the appropriate actions:  select the queue to put the customer in (NEW); remove the customer at the front of a queue (TAKE); and produce the status report (REPORT).

    The simulation should continue until the end of the DATA.P5 file is reached.  You are guaranteed that there are no extraneous commands in the file, only NEW, TAKE, and REPORT.  Also, there are never more than 10 customers in a queue at once.  Hand in program and execution printouts.