PROJECT KALKULATOR (DELPHI 7)
Posted in DELPHI 7
.............KALKULATOR..........................
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Clear; edit2.Clear; edit3.Clear;
end;
procedure TForm1.Button10Click(Sender: TObject); //ln n
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=ln(x);
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button11Click(Sender: TObject); //1/n
var x,z:real ;
begin
x:=strtofloat(edit2.Text);
z:=1/x;
edit1.Text:=floattostr(z);
Edit3.Text:='';
end;
procedure TForm1.Button22Click(Sender: TObject);
begin
edit2.Text:=edit2.Text+button23.Caption;
end;
procedure TForm1.Button28Click(Sender: TObject);
begin
edit2.Text:=edit2.Text+ '-';
end;
procedure TForm1.Button7Click(Sender: TObject); //tambah
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x+y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button6Click(Sender: TObject); //kurang
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x-y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button5Click(Sender: TObject); //kali
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x*y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button8Click(Sender: TObject); //sqrt
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=exp((1/2)*ln(x));
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button4Click(Sender: TObject); //bagi
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x/y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button9Click(Sender: TObject); //nlogk
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=ln(y)/ln(x);
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button13Click(Sender: TObject); //n^k
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=exp(y*ln(x));
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button14Click(Sender: TObject); //nCk
var a,b,i,n,r,z,j:Integer;
t:Real;
begin
a:=StrToInt(Edit2.Text);
b:=StrToInt(Edit3.Text);
n:=1;
r:=1;
z:=1;
j:=a-b;
For i:=1 to a do
n:=i*n;
Begin
For i:=1 to j do
r:=i*r;
End;
Begin
For i:=1 to b do
z:=i*z;
End;
t:=n/(z*r);
Edit1.Text:=FloatToStr(t);
if a<b then Edit1.Text:='Error';
end;
procedure TForm1.Button19Click(Sender: TObject); //nPk
var a,b,i,n,r,z,j:Integer;
t:Real;
begin
a:=StrToInt(Edit2.Text);
b:=StrToInt(Edit3.Text);
n:=1;
r:=1;
j:=a-b;
For i:=1 to a do
n:=i*n;
Begin
For i:=1 to j do
r:=i*r;
End;
t:=n/r;
Edit1.Text:=FloatToStr(t);
if a<b then Edit1.Text:='Error';
end;
procedure TForm1.Button18Click(Sender: TObject); //n!
var a,i,f:Integer;
begin
a:=StrToInt(Edit2.Text);
f:=1;
for i:=1 to a do
f:=f*i;
Edit1.Text:=IntToStr(f);
Edit3.Text:='';
end;
procedure TForm1.Button23Click(Sender: TObject); //n pnkt2
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=exp(2*ln(x));
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button25Click(Sender: TObject); //tan
var a,c:real;
begin
a:=strtofloat(edit2.Text);
c:=sin((a*pi)/180)/cos((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
procedure TForm1.Button26Click(Sender: TObject); //cos
var a,c : real;
begin
a:=strtofloat(edit2.Text);
c:=cos((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
procedure TForm1.Button24Click(Sender: TObject); //sin
var a,c:real ;
begin
a:=strtofloat(edit2.Text);
c:=sin((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
end.
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Clear; edit2.Clear; edit3.Clear;
end;
procedure TForm1.Button10Click(Sender: TObject); //ln n
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=ln(x);
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button11Click(Sender: TObject); //1/n
var x,z:real ;
begin
x:=strtofloat(edit2.Text);
z:=1/x;
edit1.Text:=floattostr(z);
Edit3.Text:='';
end;
procedure TForm1.Button22Click(Sender: TObject);
begin
edit2.Text:=edit2.Text+button23.Caption;
end;
procedure TForm1.Button28Click(Sender: TObject);
begin
edit2.Text:=edit2.Text+ '-';
end;
procedure TForm1.Button7Click(Sender: TObject); //tambah
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x+y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button6Click(Sender: TObject); //kurang
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x-y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button5Click(Sender: TObject); //kali
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x*y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button8Click(Sender: TObject); //sqrt
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=exp((1/2)*ln(x));
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button4Click(Sender: TObject); //bagi
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=x/y;
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button9Click(Sender: TObject); //nlogk
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=ln(y)/ln(x);
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button13Click(Sender: TObject); //n^k
Var x,y,z:Real;
begin
x:=StrToFloat(Edit2.Text);
y:=StrToFloat(Edit3.Text);
Z:=exp(y*ln(x));
Edit1.Text:=FloatToStr(z);
end;
procedure TForm1.Button14Click(Sender: TObject); //nCk
var a,b,i,n,r,z,j:Integer;
t:Real;
begin
a:=StrToInt(Edit2.Text);
b:=StrToInt(Edit3.Text);
n:=1;
r:=1;
z:=1;
j:=a-b;
For i:=1 to a do
n:=i*n;
Begin
For i:=1 to j do
r:=i*r;
End;
Begin
For i:=1 to b do
z:=i*z;
End;
t:=n/(z*r);
Edit1.Text:=FloatToStr(t);
if a<b then Edit1.Text:='Error';
end;
procedure TForm1.Button19Click(Sender: TObject); //nPk
var a,b,i,n,r,z,j:Integer;
t:Real;
begin
a:=StrToInt(Edit2.Text);
b:=StrToInt(Edit3.Text);
n:=1;
r:=1;
j:=a-b;
For i:=1 to a do
n:=i*n;
Begin
For i:=1 to j do
r:=i*r;
End;
t:=n/r;
Edit1.Text:=FloatToStr(t);
if a<b then Edit1.Text:='Error';
end;
procedure TForm1.Button18Click(Sender: TObject); //n!
var a,i,f:Integer;
begin
a:=StrToInt(Edit2.Text);
f:=1;
for i:=1 to a do
f:=f*i;
Edit1.Text:=IntToStr(f);
Edit3.Text:='';
end;
procedure TForm1.Button23Click(Sender: TObject); //n pnkt2
Var x,z:Real;
begin
x:=StrToFloat(Edit2.Text);
Z:=exp(2*ln(x));
Edit1.Text:=FloatToStr(z);
Edit3.Text:='';
end;
procedure TForm1.Button25Click(Sender: TObject); //tan
var a,c:real;
begin
a:=strtofloat(edit2.Text);
c:=sin((a*pi)/180)/cos((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
procedure TForm1.Button26Click(Sender: TObject); //cos
var a,c : real;
begin
a:=strtofloat(edit2.Text);
c:=cos((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
procedure TForm1.Button24Click(Sender: TObject); //sin
var a,c:real ;
begin
a:=strtofloat(edit2.Text);
c:=sin((a*pi)/180);
edit1.Text:=floattostr(c);
edit3.Text:='';
end;
end.
0 comments: