Delphi Fun

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


This is what I have so far, the only thing working is the highest number.... please help thanks so much



[color=Red]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 hi0) 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.[/color]

Comments

  • [code]
    [color=Red]program TestData;
    uses
    Forms;

    {$R *.RES}

    var
    outfile:textfile;
    number,hi,lo,A:integer;
    name:string;
    [black]Count : Integer ;[/black]

    Procedure Start;
    begin
    [black]{
    initialize
    }
    A := 0 ;
    hi := 0 ;
    lo := 32767 ;
    Count := 0 ;[/black]

    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);

    [black]
    if number < 0 then
    break ;
    A := A + number;
    if number > hi then
    hi := number;
    if number < lo then
    lo := number ;
    Count := Count + 1
    [/black]
    until number<0;

    writeln(outfile,'The Highest number is :',hi);
    writeln(outfile,'The lowest number is : ',lo);
    writeln(outfile,'The average is: ',[black]A DIV Count[/black]); [black]{ truncates }[/black]
    end;


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

    begin
    Start;
    Done;
    end.[/color]
    [/code]
  • you are the mannn thank you so much, this makes much more sense
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories