V22.0101 Homework Assignment 5 Fall 1997
A Data Base

Assigned: Thu Nov 19
Due: Thurs Dec 10 (this is the absolutely final deadline)
Final Exam: WED Dec 23 2:00-3:50pm

This assignment asks you to write some procedures for processing records in a data base. The data base will consist of an array of employee records, such as might be kept by a personnel office, together with the number of employees. Each employee record will have the type:

type EmpRecType = record
                      name: string[15];    {person's name}
                      ssn: string[10];  {social security number}
                      pay_info: array[1..3] of real;  {pay information}
                   end;
The pay information field is an array with 3 components: the first is the hourly pay, the second is the number of hours worked per week, and the third is the total amount paid per week. Notice that the amount paid per week depends on the hourly pay and the number of hours worked per week; it is not an independent quantity.

The data base itself has type:

type DataBaseType = record
                      NumEmp: integer;  {must be <= MaxEmp}
                      EmpRec: array[1..MaxEmp] of EmpRecType;
                    end;
where MaxEmp has been defined in a const statement. The data base will be a variable of type DataBaseType, i.e.\ a record with two parts: the number of employees, and the array of employee records.

The program should start by asking the user to give the name of a file where the data base requests will be stored. The purpose of this is to avoid retyping the input data as you debug the program.

Then the program should process data base requests, read from the file specified by the user. There are several kinds of requests; each one should be handled by a different procedure.

These procedures will be called as necessary by a procedure ProcessRequests, which will read directions from a file. The first letter on each line of the file indicates the type of request: A means Add, D means Delete, S means ShowAll, and M means MaxPayInfo. Here is a simple example for the input file. A longer one is available on the web page. The graders will also have their own. You can assume the input is formatted just as shown here: on the A lines, the name and social security number should be read as strings, and the hourly pay and hours worked per week should be read as real input. The D's will always be followed by the name of the string to be deleted, with blanks padded out to a special symbol # (if this is omitted, the string to be deleted might not match the string in the record since it might not be padded with blanks). You don't need to read the #, since it is given only to make sure the blanks are there in front of it. The M's will always be followed by an integer 1, 2, or 3, indicating which pay field is relevant in the search for the max value.

A Schmoe, Joe    123-45-678  4.50  20
A Schmill, Jill  347-38-765  4.75  18
S
A Zane, Jane     333-33-333  3.33  33
A Madonna        999-99-999  10000.00  0.25
A Giuliani, R    999-88-999  65.00  10
A Mojo, Mojo     123-79-432  65.00  20
A Bear, Panda    365-86-333  0.33  10
S
M 1
M 2
M 3
D Schmill, Jill  #
D Madonna        #
S
M 1


Michael Overton
Thu Nov 19 10:17:56 EST 1998