-- This program does some simple analysis of some numbers
-- read from standard input.
-- It finds the sum of all of the values, and it
-- counts the number of positive, zero, and negative values
-- It displays the sum and the counts.
--
--
-- Author: Ned Okie
-- Date: 9/7/2009
with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;
procedure getcountPZN is
Num_Ints:
constant Natural := 5; -- Number of values to input
sum: Integer := 0; -- Sum of all values
-- Number of positive, zero, and negative values
numPositives, numZeros, numNegatives: Natural := 0;
aNum: Integer; -- Temporarily holds each input number
begin
-- Input and process some values
for i in 1 .. Num_Ints loop
get(aNum);
-- Sum the number
sum := sum + aNum;
-- Count Positives
if aNum > 0 then
numPositives := numPositives + 1;
-- Count Zeros
elsif aNum = 0 then
numZeros := numZeros + 1;
-- Count Negatives
else -- aNum < 0 must be true
numNegatives := numNegatives + 1;
end if;
end loop;
-- Print sum and counts
put_line("Overall sum:" & sum'img);
put_line("Number of positives:" & numPositives'img);
put_line("Number of zeros:" & Natural'image(numZeros));
put_line("Number of Negatives:" & Integer'image(numNegatives));
end getcountPZN;