The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 51 -- Spring 1999
Project #2
Due Date: start of class, Thursday, February 4, 1999

This project is a “word problem” requiring a Case Study. It uses material mostly from Chapter 2 of the textbook, and also from the "new" Chapter 2 handout.

Here is the specification for a Min_Max package (we'll look at the body in Chapter 4):

PACKAGE Min_Max IS  
------------------------------------------------------------------  
--| specifications of functions provided by Min_Max package  
--| Author: Michael B. Feldman, The George Washington University  
--| Last Modified: July 1995  
------------------------------------------------------------------  
  
  FUNCTION Minimum (Value1, Value2: Integer) RETURN Integer;  
  -- Pre: Value1 and Value2 have been assigned values  
  -- Post: Returns the smaller of the two input values  
  
  FUNCTION Maximum (Value1, Value2: Integer) RETURN Integer;  
  -- Pre: Value1 and Value2 have been assigned values  
  -- Post: Returns the larger of the two input values  
  
END Min_Max;

First copy and compile the Min_Max package:

gcompile min_max.ads
gcompile min_max.adb

Now develop a Case Study and program to find the largest, smallest, and average of six integers read from the terminal. The average can be computed as an integer value.

Hint: Declare variables for the sum, current smallest, and current largest values. You do not need to store all six values; read them in one at a time, using the Minimum and Maximum functions from Min_Max to compare each new value to the current smallest and largest. Use a FOR loop to control the process.