with ada.text_io; use ada.text_it;
with ada.integer_text_io; use ada.integer_text_io;
with ada.float_text_io; use ada.float_text_io;
procedure g1 is
-- This procedure will print one line of the solution
procedure putline(s: String; i, n: natural) is
-- A local variable for the procedure
avg: constant float := float(i) / float(n);
begin
put(s);
set_col(10); -- Move to the correct column
put(i);
put(" ");
put(avg, fore => 4, aft => 1, exp => 0);
put("%");
new_line;
end putline;
rlo, rhi: Integer; -- Range lo and hi
total, lo, eq, hi: Natural := 0; -- counts for total, below, in, above set
num: Integer; -- Input number
begin
-- Input the range values
get(rlo);
get(rhi);
-- Sort range values into nondescending order
if rlo > rhi then
declare -- Declare a variable
t: Integer := rlo;
begin
rlo := rhi;
rhi := t;
end;
end if;
-- Get the values
while not end_of_file loop
-- Get the number
get(num);
-- Count the number
total := total + 1;
-- Classify the number
if num < rlo then
lo := lo + 1;
elsif num <= rhi then
eq := eq + 1;
else -- num > rhi
hi := hi + 1;
end if;
end loop;
-- Display results
putline("Less", lo, total);
putline("In", eq, total);
putline("Greater", hi, total);
putline("total", total, total);
end g1;