0

Alright, I'm trying to write a program that finds the highest, lowest, and average number of a set of undetermined data. The program also needs to shut off when a negative number is entered.


This is what I have so far, the only thing working is the highest number and shutting off when a negative number is entered.... please help thanks so much

program TestData;

uses
Forms;

{$R *.RES}


var
outfile:textfile;
number,hi,lo,A:integer;
name:string;


Procedure Start;

begin

assignFile(outfile,'TestData.out');
rewrite(outfile);
write('What is your name?: ');
readln(name);
writeln(outfile,'This program was run by: ',name);
writeln(outfile);
repeat
writeln('Enter your number: ',number);
readln(number);


A:=number+number;
if hi<number then hi:=number;
if (number<hi) and (number>0) and not (number=0) then lo:=number;


until number<0;
writeln(outfile,'The Highest number is :',hi);
writeln(outfile,'The lowest number is : ',lo);
writeln(outfile,'The average is: ',A);

end;


Procedure Done;
begin
writeln(outfile,'This program was created by me');
closefile(outfile);

end;

begin
Start;
Done;
end.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by jsosnowski
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.