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

The purpose of this project is 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);
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: out_array holds the values of in_array sorted smallest to largest

     FUNCTION  average (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: returns the average value of the initialized values in in_array

     FUNCTION  median  (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: returns the median value of the initialized values in in_array

     FUNCTION  mode    (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: returns the mode value of the initialized values in in_array

     FUNCTION  max     (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: returns the maximum value of the initialized values in in_array

     FUNCTION  min     (in_array : IN sort_array;
                        in_count : IN Natural) RETURN Float;
     -- Pre: in_count represents the number of initialized values in in_array
     -- Post: returns the minimum value of the initialized values in in_array

The package specification stats.ads should include the information above.

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 should be 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 a file

You will complete writing the package named stats, and write a program that reads and processes the student grade data. 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
    Mode     =>   999.9
    Minimum  =>   999.9
    Maximum  =>   999.9

Here is an example file. You may use this in your test plan, but it is not the only test you will need to complete for this program.

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); This will start reading at the line after the error was found.