unit Kakulator;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, jpeg, ComCtrls, XPMAN, MATH;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button15: TButton;
Button18: TButton;
Button23: TButton;
Button24: TButton;
Button25: TButton;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
hasil: TPanel;
StatusBar1: TStatusBar;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button25Click(Sender: TObject);
procedure Button24Click(Sender: TObject);
procedure Button27Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button29Click(Sender: TObject);
procedure Button23Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button28Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MemAngka,MemLogic,MemOperator,MemSimpan:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='1' else
Hasil.Caption:='1';
end
else
Hasil.Caption:=Hasil.Caption+'1';
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
if MemOperator<>'' then Hasil.Caption:='0' else
if Hasil.Caption='0' then Hasil.Caption:='0' else
begin
Hasil.Caption:=Hasil.Caption+'0';
MemLogic:='1';
end;
end
else
Hasil.Caption:=Hasil.Caption+'0';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='2';
if MemOperator<>'' then Hasil.Caption:='2' else
Hasil.Caption:='2';
end
else
Hasil.Caption:=Hasil.Caption+'2';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>' ' then Hasil.Caption:='3' else
Hasil.Caption:='3';
end
else
Hasil.Caption:=Hasil.Caption+'3';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='4' else
Hasil.Caption:='4';
end
else
Hasil.Caption:=Hasil.Caption+'4';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='5' else
Hasil.Caption:='5';
end
else
Hasil.Caption:=Hasil.Caption+'5';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='6' else
Hasil.Caption:='6';
end
else
Hasil.Caption:=Hasil.Caption+'6';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='7' else
Hasil.Caption:='7';
end
else
Hasil.Caption:=Hasil.Caption+'7';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='8' else
Hasil.Caption:='8';
end
else
Hasil.Caption:=Hasil.Caption+'8';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
if hasil.Caption='0' then
hasil.Caption:='';
if Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then Hasil.Caption:='9' else
Hasil.Caption:='9';
end
else
Hasil.Caption:=Hasil.Caption+'9';
end;
procedure TForm1.Button11Click(Sender: TObject);
var sudut : real;
begin
if Hasil.Caption<>' ' then
begin
sudut:=strtofloat(Hasil.Caption);
sudut:=sudut*pi/180;
Hasil.Caption := floattostr(sin(sudut));
end;
end;
procedure TForm1.Button25Click(Sender: TObject);
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then MemOperator:='-' else
if (MemOperator='') then
begin
MemOperator:='-';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
// if MemOperator='mod' then hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div strtoint(hasil.Caption));
if MemOperator='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='-';
MemLogic:='0';
end;
end;
procedure TForm1.Button24Click(Sender: TObject);
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
MemAngka:=hasil.Caption;
MemLogic:='0';
end;
procedure TForm1.Button27Click(Sender: TObject);
begin
hasil.Caption:='0';
MemLogic:='';
MemAngka:='';
MemOperator:='';
end;
procedure TForm1.Button18Click(Sender: TObject);
begin
if hasil.Caption<>'' then
hasil.Caption:=hasil.Caption + ',';
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then MemOperator:='+' else
if (MemOperator='') then
begin
MemOperator:='+';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
// if MemOperator='mod' then hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div strtoint(hasil.Caption));
if MemOperator='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='+';
MemLogic:='0';
end;
end;
procedure TForm1.Button29Click(Sender: TObject);
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then MemOperator:='x' else
if (MemOperator='') then
begin
MemOperator:='x';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
// if MemOperator='mod' then hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div strtoint(hasil.Caption));
if MemOperator='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='x';
MemLogic:='0';
end;
end;
procedure TForm1.Button23Click(Sender: TObject);
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then MemOperator:='/' else
if (MemOperator='') then
begin
MemOperator:='/';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
// if MemOperator='mod' then hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div strtoint(hasil.Caption));
if MemOperator='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='/';
MemLogic:='0';
end;
end;
procedure TForm1.Button12Click(Sender: TObject);
var sudut:real;
begin
if hasil.Caption<>'' then
begin
sudut:=strtofloat(hasil.Caption);
sudut:=sudut*pi/180;
hasil.Caption := floattostr(cos(sudut));
MemLogic :='0';
end;
end;
procedure TForm1.Button13Click(Sender: TObject);
var sudut,a,b:real;
begin
if hasil.Caption<>'' then
begin
sudut:=strtofloat(hasil.Caption);
sudut:=sudut*pi/180;
a:=sin(sudut);
b:=cos(sudut);
sudut:=a/b;
hasil.Caption := floattostr((sudut));
MemLogic :='0';
end;
end;
procedure TForm1.Button28Click(Sender: TObject);
var angka:real;
begin
angka:=StrToFloat(hasil.Caption);
if (angka>0) then
angka:=(-angka)
else
angka:=angka+(-angka)+(-angka);
hasil.Caption:=FloatToStr(angka);
end;
procedure TForm1.Button26Click(Sender: TObject);
var angka:real;
begin
angka:=StrToFloat(hasil.Caption);
angka:=ln(10)/ln(angka);
hasil.Caption:=FloatToStr(angka);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
StatusBar1.Panels[2].Text:= TimeToStr(time);
end;
end.
Tidak ada komentar:
Posting Komentar