(* Teresa Tong F.4AS 30 *)
(* to find the two roots of a quadratic equation *)
program FindingRealRoots (input, output);
uses wincrt;
var X1, X2 :real;
A ,B ,C ,D:integer;
tryagain :char;
begin
repeat
writeln('Please enter the coefficient of x square term: ');
readln(A);
writeln('Please enter the coefficient of x term: ');
readln(B);
writeln('Please enter the constant term: ');
readln(C);
D :=B*B-4*A*C;
if D<0 then
writeln('This quadratic equation has no real roots.')
else
begin
X1 :=(-B+SQRT(D))/(2*A);
X2 :=(-B-SQRT(D))/(2*A);
writeln('The roots of this quadratic equation are ',X1:5:2,' and ', X2:5:2)
end;
writeln('Continue?(Y/N) ');
readln(tryagain);
writeln;
until(tryagain='N')or(tryagain='n');
writeln('Bye Bye!')
end.
-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/--\--/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-
e.g.
Please enter the coefficient of x square term:
5
Please enter the coefficient of x term:
-10
Please enter the constant term:
-40
the roots of this quadratic equation are 4.00 and -2.00
Continue?(Y/N)
Y
Please enter the coefficient of x square term:
4
Please enter the coefficient of x term:
-2
Please enter the constant term:
-12
the roots of this quadratic equation are 2.00 and -1.50
Continue?(Y/N)
Y
Please enter the coefficient of x square term:
8
Please enter the coefficient of x term:
5
Please enter the constant term:
9
This quadratic equation has no real roots.
Continue?(Y/N)
N
Bye Bye!
               (
geocities.com/ttt_7_ttt)