-- Programmer : Robert Sebesta
-- Modifier : Elizabeth Adams
-- CS 430/530
--
-- Environment:
Windows 98 Second Edition
-- Compiler : GNAT
-- IDE : jGrasp
-- Language : Ada 95
-- Source File Name : Ada_Ex.adb
-- Executable : Ada_Ex.exe
--
-- Purpose: This
program will determine how many of the data values entered by the
-- user are above the average of all of the data values entered
by the user
-- Input: The
number of data values to be input
-- The
data values themselves
-- Output: A statement telling how many of the data values are greater
than the average
--
-- Syntax Corrections made : Text in the book had typos
-- for loop
uses for <lcv> in
<start_value> .. <final_value> loop
-- multiple statements belonging to an if, must be delimited by
begin and end
-- there should be an underscore not a period in
Ada.Integer_Text_IO;
-- Modifications to be added
-- Data entered
should be echoed
with Ada.Text_IO,
Ada.Integer_Text_IO;
use Ada.Text_IO,
Ada.Integer_Text_IO; -- I don't like use clauses
procedure Ada_Ex is
type Int_List_Type is
array(1..99) of Integer;
Int_List : Int_List_Type;
List_Len, Sum,Average,Result:
Integer;
begin
Result := 0;
Sum := 0;
Get (List_Len);
if (List_Len > 0 ) and (List_Len < 100) then
begin
for Counter in
1..List_Len loop
Get (Int_List(Counter));
Sum := Sum +
Int_List (Counter);
end loop;
Average := Sum / List_Len;
for Counter in
1.. List_Len loop
if Int_List (Counter) > Average then
Result := Result
+ 1;
end if;
end loop;
Put ("
The number of values > average is :");
Put (Result);
New_Line;
end;
else
Put_Line
(" Error-input list length is not legal");
end if;
end Ada_Ex;