Question:

I am to write a comparison program that outputs true mathematical statements. Ask the user for two numbers, and then output one of the following statements
number1>number2
number1<number2
or number1=number2

The user must also be able to keep running the program with different numbers, when they have finished running the program, thank them and tell them how many times they ran the program.

MY answer:

program Project1;

{$APPTYPE CONSOLE}


uses
  SysUtils;

var
  a, b: integer;
  answer : char;
  count : integer;

begin
  for count:=1 to 3 do
  answer:='y';
  while answer = 'y' do
    begin
      Writeln ('Please enter a number.');
      Readln(a);
      Writeln ('Please enter another number.');
      Readln(b);
    if a>b then begin
      writeln (a,' is greater than ', b);
    end
    else
      begin
        if a=b then
          begin
            writeln (a,' is equal to ', b);
          end
      else
        if b>a then
          begin
            writeln (b,' is greater than ', a);

          end;

    end;

  writeln ('Would you like to run this program again?');

  readln (answer);

    end;
  writeln ('Thank you for your running this program.');

  end.

But I am sure that my answer has some missing: thank them and tell them how many times they ran the program.

Please help me how to make changes.

Cheers,

:)

Program Program01;

Var a,b:Integer;{-32767..32768}
      Count:Integer;
      answer:Char;{0..255 characters from the ASCII table}

Begin {main}
   answer:='y';
   Count:=0;
   While (answer = 'y') Do
      Begin
         Write('Please enter a number: ');
         ReadLn(a);
         Write('Please enter another number: ');
         ReadLn(b);

         If (a>b) Then
            Begin
               WriteLn(a,' is greater than ', b);
            End;{if a>b}
         If (a=b) Then
            Begin
               WriteLn(a,' is equal to ', b);
            End;{if a=b}
         If (b>a) then
            Begin
               WriteLn(b,' is greater than ', a);
            End;{if b>a}
      WriteLn;

      WriteLn('Would you like to run this program again?Y or N');
      ReadLn (answer);

      Case (answer) of
         'Y','y':answer:='y';
         'N','n':answer:='n'
      Else answer:='n';
      End;{of case}
   Count:=Count+1;
   End;{of while}

   WriteLn('Thank you for your running this program.');
   Write('Total Run: ',Count);

   ReadLn;
End.{of main program}

{
-= Note By FlamingClaw =-
A bit  I rewrote your program for prefect working,sorry
All programs created by me are written and tested
in Dev Pascal and/or Turbo Pascal 7.0
working...
-= Created By FlamingClaw =-
-=2009.03.26=-
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.