Indiana University of Pennsylvania
Computer Science Department
CO 110   Main Session 84

   Programming Assignment #3

    For this project, you are to write a program that produces a simple report on some survey data.  A survey has been made of some families in the Indiana area and some of the collected data have been stored in a file on the system.  You can read this data by placing the following statement near the beginning of your program, before any of the READ* statements are reached.

    OPEN (105, FILE='110SURVEY.COMPSCI', USAGE='INPUT,SHARED')

    The data in this file are arranged by family surname.  For each name, there is a number indicating how many members of the family were surveyed.  For each person surveyed in a family, age and sex are the only data kept.  The first record in the file contains a single number:  the number of families.  Each other record contains the information about surveyed persons from one family.  Following is an example record.

    'WOLFE'      5 24 'F' 58 'M' 40 'F' 31 'F' 17 'M'

First is the family surname (WOLFE), then the number of persons surveyed in the family (5), then the age and sex of each of these persons (24 year old female, 58 year old male, etc.).  All family members appear in a single record of the file.

    Your program must calculate the average age for the persons in the same family and print a histogram that shows the number of family members of each sex.  In addition, the program must calculate the overall average age of everyone surveyed and the total number of males and females who were surveyed.  Based on these calculations, the program must print a report in the following form.

                   SURVEY RESULTS
                                              11111111112
                                    |12345678901234567890
NAME              AVERAGE AGE       |--------------------
nnnnnnnnnn             xx.xx        |****#######
.                        .               .
.                        .               .

OVERALL AVERAGE AGE IS  xx.xxx

TOTAL NUMBER OF FEMALES IS    xxx

TOTAL NUMBER OF MALES IS      xxx

Here n is a letter in the family name (names have up to 16 letters); x is a digit in a numeric value; each * represents one male family member; and each # represents one female family member.

    After printing out these initial results, your program must print out the names of the families that fall into two categories:  (1) families whose family average age is below the overall average and who had more males than females surveyed, and (2) families whose family average age is above the overall average and who had more females than males surveyed.  These printouts should be in the following form.

    ------- Category Description ---------
         nnnnnnnnn                nnnnnnnnn
         .                        .
         .                        .

    You must hand in a batch listing of your program with output.  In order to get this batch listing, you must build a file containing IBEX commands.  Such a file is called a JCL file and should contain the following commands, beginning in column 1 with an exclamation point.  Note:  these commands assume your FORTRAN program is in a file called PROG-3.

    !JOB  SCAN
    !FORTRAN PROG-3(LS)
    !RUN

Assume that you call your JCL file JCL-3.  Then, in order to get the batch listing and output, you must give the following command at your terminal.

    BATCH JCL-3

While developing your program, you can cause the commands in the JCL file to be executed with the listing and output sent to your terminal.  You do this by giving the following command at your terminal.

    XEQ JCL-3


Program Requirements

1.  All output must be done using formatted PRINT statements.

2.  Family average age must have 2 fractional digits; the overall average age must have 3 fractional digits.

3.  The survey report must begin on a new page.

4.  Titles shown in the output forms (in uppercase letters) must be as shown, spacing both horizontally and vertically may vary.

5.  Names listed for the two categories must be listed in two columns, as shown.

6.  You must use arrays and implied DO loops to perform some of the tasks in this program.  Actually, some tasks cannot be performed in any other way.

7.  Your program must be able to handle up to 50 families and up to 20 members per family.  However, your program should be written in such a way that these limits can easily be changed.

8.  Documentation requirements are the usual; no flow diagram is needed.


-----------------------------------------------------------------


Fancy Option

When printing the histogram, print the number of family members one space after the last symbol (* or #).

There is NO extra credit for doing this option.  You should consider doing it only if you have the time and interest.  Some statements/features not in the text book (but in the reference manual) may be required.