1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| {Author : Leon
Description : Resolves Lvl2 Equations of the form Ax²+Bx+C}
program equation2; {AX²+BX+C}
var
A,B,C:real;
DELTA:real;
X0,X1,X2:real;
procedure start;
begin
writeln('Welcome to EquaTOR!');
writeln('I will solve your lvl2 equations faster than your math prof & as fast as a computer');
writeln('First, be sure that the equations are under this form');
writeln;
writeln('Ax²+Bx+C');
writeln('Give me respectively,A then B and then C');
readln(A,B,C);
writeln('Ok let''s get started!!!');
end;
procedure calc_delta;
begin
delta := (b*b)+(-4*A*C);
end;
procedure check_delta;
begin
case delta of
> 0 : deltaplus;
< 0 : deltanone;
= 0 : deltaabs;
end;
procedure deltaplus;
begin
X1 := ((B*-1)-sqrt(DELTA)) div (2 * A);
X2 := ((B*-1)+sqrt(DELTA)) div (2 * A);
writeln('The Two results are :',X1,'and :',X2);
writeln('See, that was fast :) ');
end;
procedure deltanone;
begin
writeln('Since delta has revealed to be a value under 0, there are no solutions to this equation');
end;
procedure deltaabs;
begin
X0 := (B*-1) div (2*A);
writeln('There is only one solution and it''s :',X0);
end;
begin
start;
calc_delta;
check_delta;
readln;
end. |
Partager