Indiana University of Pennsylvania CO 110
Computer Science
Spring 1984
McKelvey and Wolfe

   Programming Project #5

    For project #5, you are to write a program that can respond to a series of commands by doing specific tasks. The emphasis is on modularization (using SUBROUTINEs and FUNCTIONs).

    The data for the program consists of information about students in a particular course.  The data is in a file which you can access by placing the following statement near the beginning of your program.

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

The first line of the file contains a number which is the total number of students in the file.  All other lines in the file contain the following student information in order:  Student name, Social security no., 1st exam score, and 2nd exam score. The name is up to 12 characters long; other values are integers.

    Begin by reading into arrays the student information for all students.  There are no more than 50 student records  in the file.  Then, sort the information so that the students can be accessed alphabetically.  This sorting may be done by a subroutine.  Note:  after the reading, your program must perform the following statements.

       CLOSE (105)
       OPEN (105, FILE='ME')

    Next, your program must read commands from the terminal or the JCL file and perform the requested actions.  There are five types of commands; each is described below.

    Command        Program Action or Task
    -------        ----------------------
    'LIST'         Print the information about all students who
                   meet the selection criteria (these are
                   specified on the next input line).

    'CHOOSE'       Print the information about all students
                   whose social security numbers end with a
                   particular digit (specified on next line).

    'WITHDRAW'     Remove from the arrays all information about
                   a student whose name is specified (on the
                   next line).

    'RANGE'        Print the range of scores (high and low)
                   for the exam specified on the next line.

    'END'          Terminate the program.

    Each command (except END) requires an auxiliary specification line which immediately follows the command line.   For LIST, this line contains the exam number (1 or 2), the lowest allowed score and the highest allowed score.  Students whose scores on the specified exam fall between the low and high should have their information printed.  For CHOOSE, the line contains a single digit.  Students whose social security numbers end with this digit should have their information printed.  For WITHDRAW, the line contains a name.  The named student should have his/her information removed from the arrays.  For RANGE, the line contains an exam number.  The highest and lowest scores for the specified exam should be printed.

    To perform these actions, your program is required to use at least three subroutines and two functions, all written by you.  You must have each of the following subprograms and they must perform as specified.  Each of these subprograms requires the use of at least one array and the number of elements in the array as arguments (most require several other arguments).

    Name      Type and Action
    ----      ---------------
    BIG       Function.  Finds the largest number in an array.

    SMALL     Function.  Finds the smallest number in an array.

    SELECT    Subroutine.  Builds a pointer array of student
              entries that meet the specified criteria.  These
              criteria may be the high and low limits for an
              exam or the last digit of a social security no.

    REMOVE    Subroutine.  Eliminates the entry in each array
              for a named student; adjusts number of students.

    SHOW      Subroutine.  Prints the information about all
              students whose entries are in a pointer array.
              Note:  any printout of student information must
              list the students in alphabetical order.

    Provide the usual documentation:  program title, your name and recitation section number, a program description, and a data table.  Document each subprogram with a description of what it does and a data/argument table.

    You may test your program by running it at the terminal with your own command data; however, when it is ready to turn it, you must run it in a batch job using the command data on the next page.  For the batch job, the command data should be placed in the JCL file after the !RUN command.

    Your program need not check for invalid exam numbers, last digits, or low and high scores.  However, your program should handle each of the following error conditions by printing out an appropriate message.
    1.  Unknown command.  For example, suppose 'LOST' is typed
        instead of 'LIST'.

    2.  Unknown name.  For example, suppose you try to WITHDRAW
        'ANGELA' and there is no student by that name.

    3.  No student meets criteria.  For example, suppose you try
        to LIST students whose score on exam #2 is between 20
        and 25 and there aren't any.

    When your program is in its final form, run it with the following command data.

   'LIST'
         1    0    100
   'RANGE'
         2
   'WITHDRAW'
         'JEANNIE'
   'CHOOSE'
         2
   'LIST'
         2    70   80
   'WITHDRAW'
         'CAROLINE'
   'WITHDRAW'
         'KEITH'
   'RANGE'
         2
   'CHOOSE'
         7
   'LIST'
         1    0    100
   'END'


    The following is a sample of the output form expected for the processing of each of the commands.

LIST and CHOOSE     

              Criteria for the Listing

    NAME           SSN            EXAM #1   EXAM #2
    nnnnnnnnnnnn   ddddddddd        ddd       ddd
    .              .                .         .

RANGE

    FOR EXAM n, THE HIGH IS ddd AND THE LOW IS ddd

WITHDRAW

    STUDENT nnnnnnnnnnnn IS WITHDRAWN