The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 51 -- Fall 1998
Project #7
Due Date: start of class, Thursday, 5 November 1998

The purpose of this project is to help you get more familiar with FUNCTIONs, PROCEDUREs, and TASKs and to introduce arrays.

You are going to create a PACKAGE named "Stats". This package provides the following:

     TYPE sort_array IS ARRAY (1..100) of Float;
     PROCEDURE sort    (in_array  : IN sort_array; 
                        out_array : OUT sort_array;
                        in_count  : IN Natural);
     FUNCTION  average (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     FUNCTION  median  (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     FUNCTION  max     (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     FUNCTION  min     (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;

The package specification stats.ads is already written. In addition, part of the package body stats.adb is already written. Also, stored with the package is ALL the test data for this project. The files are stored in the directory named ~csada/clund/proj_07. To copy the files to your current directory use the following Unix command: cp ~csada/clund/proj_07/*.* .

You will use this package to analyze student test scores. These test scores have values in the range from 0.0 to 100.0. In addition, there are some comments and junk in the input data. Your program will use exception handling to bypass the non-numeric data. Finally, your program will read its input from the file scores.dat. There are three sets of test data in the file scores.dat; your program must process all three sets of data.

Part One: Simple Program

In Part One you will complete writing the package named stats, and write a program that reads and processes the student grade data. Remember to follow the program organization given in class; this program minimizes the differences between Part One and Part Two. The format of the program report should be the following:

Comments detected in input data, comment ignored
Score detected out of range, value ignored

Set Number 1
=======================
    Students =>   999
    Average  =>   999.9
    Median   =>   999.9
    Minimum  =>   999.9
    Maximum  =>   999.9

Part Two: Using TASKs

Revise the program created in Part One such that reading the input file and writing the report are done concurrently (by separate tasks). A simple hint for doing this is included in the file proj_samp.adb.

Do not do a case study for Part Two. Do a case study for Part One only.

Notes about Files:

To open an input file from which your program will read, your program will contain a variable declaration:

scores : Ada.Text_IO.File_Type;

To associate the file name with an input file in the file system, include this statement after the BEGIN of your program:

Ada.Text_IO.open (File => scores,            --  Open input file
                  Mode => Ada.Text_IO.in_file,
                  Name => "scores.dat"); 

To read a float value from this file, use the file-oriented Ada.Text_IO operations, for example, if student_grade is a float variable, use

Ada.Float_Text_IO.get (File => scores, Item => student_grade);

Remember to include into your exception handler the following statement:

Ada.Text_IO.skip_line (File => scores);