unit sqrt;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Math;
type
TForm1 =
class(TForm)
Edit_a: TEdit;
Edit_b: TEdit;
Edit_c: TEdit;
Edit_x1: TEdit;
Edit_x2: TEdit;
Button_solve: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button_clear: TButton;
Button_exit: TButton;
procedure Edit_bExit(Sender: TObject);
procedure Edit_cExit(Sender: TObject);
procedure Button_solveClick(Sender: TObject);
procedure Button_exitClick(Sender: TObject);
procedure Button_clearClick(Sender: TObject);
procedure Edit_bEnter(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
a,b,c,d,e,x1,x2 :real;
implementation
{$R *.DFM}
procedure TForm1.Edit_bExit(Sender: TObject);
begin
b:=strtofloat(edit_b.text);
end;
procedure TForm1.Edit_cExit(Sender: TObject);
begin
c:=strtofloat(edit_c.text);
end;
procedure TForm1.Button_solveClick(Sender: TObject);
begin
if a <> 0
then
begin
d:=(sqr(b))-(4*a*c);
if d > 0
then
begin
e:=sqrt(d);
//[u][b]<-------- Fehlerstelle !![/b][/u]
x1:=(-b+e)/(2*a);
x2:=(-b-e)/(2*a);
edit_x1.Text:=floattostr(x1);
edit_x2.text:=floattostr(x2);
end
else
showmessage('
Aus negativen Zahlen kann keine Wurzel gezogen werden!');
end
else
showmessage('
Division durch 0 ist unzulässig!');
end;
procedure TForm1.Button_exitClick(Sender: TObject);
begin
close;
end;
procedure TForm1.Button_clearClick(Sender: TObject);
begin
edit_a.Clear;
edit_b.Clear;
edit_c.Clear;
edit_x1.Clear;
edit_x2.Clear;
end;
procedure TForm1.Edit_bEnter(Sender: TObject);
begin
a:=strtofloat(edit_a.text);
end;
end.