Tuesday, January 11, 2011

0

PROJECT PERSAMAAN KUADRAT (DELPHI 7)

Posted in
.....................PERSAMAAN KUARAT......................................

X1=EDIT1,X2=EDIT2, A=EDIT3,B=EDIT4,C=EDIT5, KET,EDIT6

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button1Click(Sender: TObject); //HITUNG
 Var
    a,b,c,D,m,n,q:Real;
    x1,x2:Real;
begin
    a:=StrToFloat(Edit3.Text);
    b:=StrToFloat(Edit4.Text);
    c:=StrToFloat(Edit5.Text);
    D:=b*b-4*a*c;
    if D>0 then
begin
    x1:=(-b+sqrt(D))/(2*a);
    Edit1.Text:=FloatToStr(x1);
    x2:=(-b-sqrt(D))/(2*a);
    Edit2.Text:=FloatToStr(x2);
    Edit6.Text:='Dua akar Berbeda';
end;
    if D=0 then
begin
    x1:=(-b/(2*a));
    Edit1.Text:=FloatToStr(x1);
    x2:=(-b/(2*a));
    Edit2.Text:=FloatToStr(x2);
    Edit6.Text:='Dua Akar Kembar';
end;
    if D<0 then
begin
    m:=-1*D;
    n:=(-b/(2*a));
    q:=(sqrt(m)/(2*a));
    Edit1.Text:=FloatToStr(n)+'+'+FloatToStr(q)+'i';
    Edit2.Text:=FloatToStr(n)+'-'+FloatToStr(q)+'i';
    Edit6.Text:='Dua Akar Imajiner';
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
  edit3.clear; edit4.Clear; edit5.clear;
end;

end.

0 comments: