unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit7: TEdit;
Edit8: TEdit;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Edit9: TEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
Procedure kuerze(a,b:real;
var c,d:real);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
z,n,x1,x2,a,p,px,p2,q,disk,p5,e,z1,n1:real;
begin
a:= strtofloat(edit1.text) / strtofloat(edit2.text);
px:= strtofloat(edit3.text) / strtofloat(edit4.text);
p:=px / a;
q:= (strtofloat(edit5.text) / strtofloat(edit6.text))/a;
p2:=p / 2;
disk:=sqr(p2) -q;
if disk<0
then begin
edit7.text:='
';
edit8.text:='
';
edit9.text:='
Keine Lösung'
end
else if disk>0
then begin
edit9.text:='
Zwei Lösungen';
x1:=-p/2+sqrt(disk);
x1:=round(x1 * 100) / 100 ;
x2:=p/2+sqrt(disk);
x2:=round(x2 * 100) / 100 ;
edit7.text:='
'+floattostr(x1);
edit8.text:='
'+floattostr(x2);
end
else if disk=0
then begin
edit9.text:='
Eine Lösungen';
e:=-p/2;
x1:=e;
x1:=round(x1 * 100) / 100;
edit7.text:='
'+floattostr (x1);
edit8.text:='
';
end;
z:=strtofloat (form1.edit1.text);
n:=strtofloat(form1.edit2.text);
form1.kuerze (z,n,z1,n1);
form1.edit1.text:=floattostr(z1);
form1.edit2.text:=floattostr(n1);
end;
Procedure TForm1.kuerze(a,b:real;
var c,d:real);
var teiler:real;
begin
teiler:=a;
while (a
mod teiler <>
{!!!Operator ist auf diesen Operandentyp nicht anwendbar!!!} 0)
or (b
mod teiler <>0)
do
teiler:=teiler-1;
c:=a
div teiler;
d:=b
div teiler;}
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if checkbox1.checked=false
then begin
edit2.visible:=false;
edit4.visible:=false;
edit6.visible:=false;
edit2.text:='
1';
edit4.text:='
1';
edit6.text:='
1';
label7.visible:=false;
label8.visible:=false;
label9.visible:=false;
edit1.top:=77;
edit3.top:=77;
edit5.top:=77;
end
else begin
edit2.visible:=true;
edit4.visible:=true;
edit6.visible:=true;
label7.visible:=true;
label8.visible:=true;
label9.visible:=true;
edit1.top:=64;
edit3.top:=64;
edit5.top:=64;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edit2.visible:=false;
edit4.visible:=false;
edit6.visible:=false;
edit2.text:='
1';
edit4.text:='
1';
edit6.text:='
1';
label7.visible:=false;
label8.visible:=false;
label9.visible:=false;
edit1.top:=77;
edit3.top:=77;
edit5.top:=77;
end;
end.