Sabtu, 19 November 2016

Program Delphi Untuk Mencari Akar-akar Persamaan Kuadrat

procedure TPersamaanKuadrat.Button1Click(Sender: TObject);
var
  a,b,c:integer;
  D,AD,akr1,akr2,e,f:real;
begin
  a:=StrToInt(Edit1.Text);
  b:=StrToInt(Edit2.Text);
  c:=StrToInt(Edit3.Text);
  D:=(b*b-4*a*c);
  if(D>0)then
  AD:=sqrt(b*b-4*a*c);
begin
  akr1:=(-b+AD)/(2*a);
  akr2:=(-b-AD)/(2*a);
  Edit4.Text:=FloatToStr(akr1);
  Edit5.Text:=FloatToStr(akr2);
  Edit6.Text:='Real Berlainan';
end;
  if(D=0)then
 
begin
  akr1:= -b/(2*a);
  akr2:= -b/(2*a);
  Edit4.Text:=FloatToStr(akr1);
  Edit5.Text:=FloatToStr(akr2);
  Edit6.Text:='Real dan Sama';
end;
  if(D<0)then
begin
  e:=-b/(2*a);
  f:=sqrt(-D)/(2*a);
  Edit4.Text:=FloatToStr(e)+' + i' + FloatToStr(f);
  Edit5.Text:=FloatToStr(e)+' - i' + FloatToStr(f);
  Edit6.Text:='Real Imajiner'
end;

end;

procedure TPersamaanKuadrat.Button2Click(Sender: TObject);
begin
edit1.text:=' ';
edit2.text:=' ';
edit3.text:=' ';
edit4.text:=' ';
edit5.text:=' ';
edit6.text:=' ';
end;

procedure TPersamaanKuadrat.Button3Click(Sender: TObject);
begin
MainMenu.Show;
PersamaanKuadrat.Hide;
end;

procedure TPersamaanKuadrat.Panel3Click(Sender: TObject);
begin
edit1.text:=' ';
edit2.text:=' ';
edit3.text:=' ';
edit4.text:=' ';
edit5.text:=' ';
edit6.text:=' ';

end;

procedure TPersamaanKuadrat.Panel4Click(Sender: TObject);
begin
MainMenu.Show;
PersamaanKuadrat.Hide;

end;

end.

0 komentar:

Posting Komentar