In this program a set of questions are asked and user has to find the correct answers

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategorija: KMP (Programy mladňakoch

Program: Mathspro.pas
Subor exe: Mathspro.exe

In this program a set of questions are asked and user has to find the correct answers.
{ MATHSPRO.PAS                                                      }
{ In this program a set of questions are asked and user has to find }
{ the correct answers.                                              }
{                                                                   }
{ Author: Unknown                                                   }
{ Datum:20.01.2009                             http://www.trsek.com }
 
program maths_problem;
 
uses crt;
 
var
 x: integer;
 x2:integer;
 y:integer;
 z:integer;
 u:integer;
 counter:integer;
 
begin
 clrscr;
 counter := 0;
 textcolor (yellow+blink);
 writeln('             PLEASE USE A ROUGH PAPAER FOR YOUR WORKING!! THANK YOU!!');
 writeln;
 writeln;
 writeln;
 textcolor (15);
 writeln('1) John has x pencils and Kate has 7 pencils. Mike has 2x+y pencils.');
 writeln('  together John and Kate have 10 pencils and Mike has 15 pencils.Find x,2x and y');
 write ('ans of x is ');
 readln(x);
  if (x = 3)
   then
    begin
     writeln;
     writeln ('Correct answer');
    end
   else
    begin
     writeln;
     writeln ('Wrong answer');
    end;
 writeln;
 write ('ans of 2x is ');
 readln(x2);
 if (x2 = 6)
  then
  begin
   writeln;
   writeln ('Correct answer');
  end
 else
  begin
   writeln;
   writeln ('Wrong answer');
  end;
 writeln;
 write ('ans of y is ');
 readln(y);
 if (y=9)
  then
   begin
    writeln;
    writeln ('Correct answer');
   end
  else
   begin
    writeln;
    writeln ('Wrong answer');
   end;
 if (x = 3) and (x2 = 6) and (y=9)
   then
    begin
     counter := counter + 1;
    end;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln ('2) Sam has G+y-z candy and Mary has 10 more candy then Sam.');
 writeln ('  Together Sam and Mary have 50 pieces of candy. Find z if G=10,y=G+5.');
 
 writeln;
 Write ('ans of z is ');
 read(z);
 if (z=5)
 then
  begin
   writeln;
   writeln ('Correct answer');
    counter :=counter+1;
  end
 else
  begin
   writeln;
   writeln ('Wrong answer.');
  end;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
 writeln;
  writeln ('3)  Alis has 9-i plants and  Mark has u+i plants.');
 writeln (' Together They have 16 plants.Find u if i=4.');
 writeln;
 Write ('ans of u is ');
 read(u);
 if (u=7)
 then
  begin
   writeln;
   writeln ('Correct answer');
    counter :=counter+1;
  end
 else
  begin
   writeln;
   writeln ('Wrong answer.');
 
  end;
  writeln;
  writeln;
  writeln;
  if counter = 3 then
   begin
   textcolor (blue+blink);
    writeln('                  Congratulations all answers are correct!!!');
   end;
   if counter = 2 then
  begin
  textcolor (green+blink);
   writeln ('                 You scored 2 out of 3');
   end;
   if counter = 1 then
   begin
   textcolor (yellow+blink);
   writeln ('                 You scored 1 out of 3');
   end;
   if counter = 0 then
   begin
   textcolor (red+blink);
   writeln ('              Sorry all your answers are incorrect');
   end;
    readkey;
end.