Codigo de Ecuacion de Segundo Grado
-
Upload
ernest-van-bakker -
Category
Documents
-
view
221 -
download
0
Transcript of Codigo de Ecuacion de Segundo Grado
-
7/25/2019 Codigo de Ecuacion de Segundo Grado
1/2
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math;
type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button1: TButton; Label2: TLabel; Label3: TLabel; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);varx1,x2,a,b,c,d,Re,Im: Extended;
// Las variables Re e Im son la parte real e imaginaria para las raices complejas
begina:= StrToFloat(Edit1.Text);b:= StrToFloat(Edit2.Text);c:= StrToFloat(Edit3.Text);d:= b*b-4*a*c;
if a0 then begin if d>0 then begin
x1:= RoundTo((-b + Sqrt(d))/2/a,-2); x2:= RoundTo((-b - Sqrt(d))/2/a,-2);
Label2.Caption:= 'x1'+' = '+FloatToStr(x1); Label3.Caption:= 'x2'+' = '+FloatToStr(x2); end else
if d=0 then begin
-
7/25/2019 Codigo de Ecuacion de Segundo Grado
2/2
x1:= RoundTo(-b/2/a,-2);
Label2.Caption:= 'x1'+' = '+FloatToStr(x1); Label3.Caption:= 'x2'+' = '+FloatToStr(x1); end else
if d