|
CS 103 Programming
Assignment 2 |
|
Statement of the Problem:
This assignment
involves modeling a group of customers and a service-counter on a
typical day from
Definition: A break is the period
of time between the end of serving one person and the beginning of serving the
next person. If the next person is right there, waiting in the queue, the break
length is 0. Note that if the last person in the group is done before
Definition: The total idle time of the employee is the sum of the lengths of the breaks that the employee ends up having.
The precise formatting of the queries and answers for your program is detailed below.
The Input:
Your program will take two input files from the command prompt.
The first file, called customersfile.txt, has the customers information, such that each customer has one "paragraph" of two lines, with at least one blank line between one paragraph and the next. The format of the paragraph of a customer is:
ID-NUMBER: a unique integer customer
id
ARRIVAL-TIME: hh:mm:ss
For example, for a
person arriving 15 minutes and 27 seconds after
The first line of customersfile.txt is an unsigned positive integer, representing the constant service time per customer, in seconds. After that line there is at least one blank line. After that, the 2-line paragraphs follow.
Note that some customers may arrive before
You are guaranteed that the arrival times of the
customers in customersfile.txt are in
chronological order. That is, the arrival time of a customer A is greater than
the arrival times of all the customers that occur before A in the input file. Also,
you are guaranteed that all customers ids are positive, and no customer id
occurs multiple times in the input file.
The second input file, called queriesfile.txt, will have a sequence of queries, one query per line, where the queries can be:
WAITING-TIME-OF
customer-id //
measured in seconds
NUMBER-OF-CUSTOMERS-SERVED
LONGEST-BREAK-LENGTH //
measured in seconds
TOTAL-IDLE-TIME
// measured in seconds
MAXIMUM-NUMBER-OF-PEOPLE-IN-QUEUE-AT-ANY-TIME
Note that there could be many queries beginning with WAITING-TIME-OF but ending with different id numbers.
The output:
Your program must take as input the two input files above, in that order. That is, we should be able to compile your program into an executable file (called Program2, say), then call it from the command-line like this:
>> Program2 customersfile.txt queriesfile.txt
Your program must then output as many lines as there are query lines: the kth output line should be the answer to the kth query line in file queriesfile.txt. Your output line answer to a query should begin by repeating the exact same query, followed by a colon (:), followed by the query-answer.