IUP Computer Science
CO 110   Fall 86
Wolfe, Cunningham, Maple

 Programming Project #6

    The Forestry Service is in the midst of taking a special tree survey of a large part of State Forest lands in Indiana county.  For this survey, two fledgling forestry officers (Doug and Cindy) are randomly going to various areas of the county and gathering information about cherry trees, hickory trees and walnut trees.  The information includes the numbers, ages, and health of such trees.

    To help organize the findings of the survey, the county has been divided into quadrangles.  Thus, the officers can report their findings for each quadrangle area.  Each week, Cindy and Doug separately enter the information collected into files.  Each file contains records in the following form.

  Columns 1-4      The quadrangle identifier.
  Column 5         Blank
  Columns 6-7,     The number of cherry trees (C), number of
          8-9,     hickory trees (H), and number of walnut trees
         10-11     (W) in that order - each as a 2-digit number.
  3 column groups  The age (a 2-digit number) and health rating
    (starting in   of a tree.  The health is E (for excellent),
     column 12)    G (for good), F (for fair), or P (for poor).
                   There are C groups for the cherry trees;
                   this is followed immediately by H groups for
                   the hickory trees; followed by W groups for
                   the walnut trees.

As an example, consider this record for the BT14 quadrangle.

    BT14 03010416G27F06G32G18E30P60P44G

This shows that there are 3 cherry, 1 hickory and 4 walnut trees.   The cherry trees are age 16 (in good health), 27 (fair) and 6 (good).  The hickory tree is age 32 and in good health.  The walnut trees are age 18 (excellent), 30 (poor), 60 (poor) and 44 (good).

    Doug's survey records are in a file called 110DOUG.COMPSCI and Cindy's survey records are in a file called 110CINDY.COMPSCI.   The records in both files are already sorted in ascending order based on the quadrangle identifier.

    For project 6, you are to write a program that does two things:  merges the records from Cindy's and Doug's files into a single file that represents all survey information for the week, and produces a small report about the quadrangles being surveyed.

   Although Cindy and Doug work independently, odds are that they have surveyed some of the same quadrangles.  As the merging proceeds, records with matching quadrangle numbers should be combined into a single record for the merge file.

   The merge file should be called SURVEYDATA and should hold the quadrangle records in ascending order.  DO NOT TRY TO CREATE THIS FILE IN .COMPSCI; IT MUST BE IN YOUR OWN ACCOUNT.  The form of the records in SURVEYDATA must be as follows.

  Column 1         Number of officers surveying the quadrangle
  Columns 3-6      Quadrangle identifier
  Columns 8-9,     Numbers of cherry, hickory and walnut trees
    10-11, 12-13   (as in Doug and Cindy's files).  If two
                   matching records are combined, these numbers
                   should be the sums of the values from the
                   individual records. MUST BE 2-DIGIT NUMBERS.
  3 column groups  Age and health groups as in Cindy and Doug's
    (starting in   files, with cherry tree groups first, hickory
     column 15)    tree groups second and walnut tree groups
                   last.  Make sure tree groups are in this
                   order for matching records.  THE AGES MUST BE
                   2-DIGIT NUMBERS, EVEN WITH LEADING ZERO.

   You are guaranteed that even with matching records, Doug and Cindy will not find more than 10 trees of any one type in a quadrangle.  You may assume that, even when the officers survey the same quadrangle, the collected information is about different trees.  They never record information about the same trees.

   The report that your program produces should show the following information for each quadrangle.

Quadrangle    # cherry   # hickory   # walnut   Average   Average
Identifier      trees      trees       trees     age       health

The average age includes ALL trees of all types that were found in the quadrangle.  The average health also includes all trees.   For the health, excellent counts 4, good counts 3, fair counts 2, and poor counts 1.  Don't forget to include trees from both records of on a match.  Print only one line for each quadrangle.   Create suitable titles for the columns and the overall report; print the report starting on a new page.

   You must handin a program listing and output from a batch run of your program.  Place the following command after the !RUN command in your JCL file:

  !COPY SURVEYDATA

This will cause a listing of the SURVEYDATA file to be printed after your program's output.  WE WANT TO SEE THIS LISTING.

   Documentation requirements are the usual:  identification, data table, brief program description, and comments for major steps.  No flowchart is required.  CAUTION:  do not use unit numbers for the files that are between 0 and 9 or between 100 and 109.  These have special meaning for FORTRAN.