Indiana University of Pennsylvania
Computer Science Department
CO 110   Spring 1985
Wolfe and Maple

  Programming Project #6

    For project 6, you are to write a program to update a bird observation file which keeps track of observations made by the Indiana Bird Watcher's Club.  All observations made by club members so far this year are recorded in a file called THRU-MARCH.COMPSCI.  This file contains one record for each club member who has reported any observations.  The form of these records is given below.

Columns 1-9        Social security number of the club member
Columns 10-11      Number of species observed so far this year
Columns 12-14, 15-17, 18-20, etc.
                   Three-digit species code numbers.  There is
                   one number for each specie observed so far
                   this year.  The numbers are in chronological
                   order (1st number is the 1st observation).

For example, the following record is for the club member whose social security number is 148345566.  This member has observed 6 species, whose code numbers are 031, 037, 126, 087, 113, and 020.

    14834556606031037126087113020

    The observation updates for the month of April are contained in the file APRIL-UPDATES.COMPSCI.  Your program must read in the April updates and combine them with the year-to-date observations to produce a new file containing all observations through April.   The form of the records in the update file is given below.

Column 1      Update code letter:  A - indicates that the
              specified species numbers should be added to the
              specified club member's record,  D - indicates
              that the specified species numbers should be
              deleted (removed) from the specified club member's
              record.
Column 2-10   Social security number of the club member
Column 12-13  Number of new species observed in April
Column 15-17, 18-20, etc.
              Three-digit species code numbers for the new
              species observed in April.

For example, the following record shows additions to member 148345566's observations for April.

    A14834556603143161090

Your program should combine this update with the record from the observations file and write the following record into a file called THRU-APRIL.

    14834556609031037126087113020143161090

New observations must be added to the end of the observation record (so it remains chronological).  If there is no previous observation record for a club member, a new record should be added to the THRU-APRIL file on the basis of the update record.

    Your program should allow for any number of members in the club.  The total number of species that have been observed (including April's observations) for any club member will not be more than 40.  The species code numbers range from 001 through 215.  There will be no more than one update record for any club member.  Many members will have no updates; their records should be copied as-is from the THRU-MARCH file to the THRU-APRIL file.   The records in both the THRU-MARCH and APRIL-UPDATES files are in ascending order on club member social security numbers.  Thus, you can process these files and produce the THRU-APRIL file using a modified sequential file update program.

    As your program reads the two input files and writes the THRU-APRIL file, it must also collect information from the update and observation records to produce a report showing the following.

1.  The total number of new observations in April - the sum of the numbers of new species for all addition updates.

2.  The number of club members with addition updates, the number of club members with deletion updates, and the number of data errors in the updates.

3.  A list of the species codes seen by any club member any time during the year, including April.

You have some freedom in choosing the form of this report; however, the following form is suggested.

    NUMBER OF NEW OBSERVATIONS  xxx
    NUMBER OF ADDITIONS         xxx      
    NUMBER OF DELETIONS         xxx
    NUMBER OF DATA ERRORS       xxx

    SPECIES SEEN THROUGH APRIL

    xxx       xxx       xxx       xxx       xxx       xxx

    xxx       xxx       xxx       xxx       xxx       xxx

     .         .         .         .         .         .

    You must hand in a program listing and the report produced by doing a batched run of your program.  Your batch (JCL) file must also produce a copy of the THRU-APRIL file and make this file readable by a grading program.  Put the following commands at the end of the JCL file (after the !RUN).

    !COPY THRU-APRIL
    !MODIFY THRU-APRIL TO (RD=ALL)


    The records in the THRU-MARCH.COMPSCI file are guaranteed to be error free; however, there may be errors in the records in the APRIL-UPDATES.COMPSCI file.  These errors may be of the following types.

    1.  Invalid species numbers (less than 001 or more than 215)

    2.  Invalid update code (a character other than A or D in column 1)

    3.  Invalid number of species (less than 0 or more than 40)

When any of these errors occurs, your program must count it as a data error and NOT try to apply the update to the observation file.  Also, the program must not count any error record as an addition or a deletion. Note:  you do not need to worry about adding a duplicate species number to the observation list.  Also, you are guaranteed that the species code for any deletion is actually in the observation record from the THRU-MARCH file.

IMPORTANT NOTES

1.  All input and output for this program must be FORMATTED.

2.  Documentation within the program must be of the same form as in previous programs.

3.  When opening and using these files, don't use unit numbers that are between 0 and 9 or between 100 and 109.

4.  The THRU-APRIL file must be written in you own account.  Do not try to write it to the COMPSCI account.  You will get an error.

5.  Be sure that all references to species code numbers are a full three digits when printing them and when writing them to a file.  Also make sure that the number of species seen is a full two-digit number when it is written to the file.

6.  It is recommended that you use a subroutine to keep track of which species have been seen.  The listing of "species seen through April" should be in ascending order.

7.  Be sure the program you hand in is your own work.  This program will be carefully scrutinized for plagiarism and collaboration; heavy penalties will be assessed on offenders.