Вы находитесь на странице: 1из 20

unit dhelpi;

interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, jpeg;

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; Button14: TButton; Button15: TButton;

Button16: TButton; Button17: TButton; Button18: TButton; Button19: TButton; Button20: TButton; Button21: TButton; Button22: TButton; Button23: TButton; Button24: TButton; Button25: TButton; Button26: TButton; Button27: TButton; Button28: TButton; Button29: TButton; edit1: TPanel; 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 Button19Click(Sender: TObject); procedure Button12Click(Sender: TObject); procedure Button13Click(Sender: TObject); procedure Button20Click(Sender: TObject); procedure Button21Click(Sender: TObject); procedure Button22Click(Sender: TObject); procedure Button28Click(Sender: TObject); procedure Button26Click(Sender: TObject); procedure Button14Click(Sender: TObject); procedure Button17Click(Sender: TObject); procedure Button16Click(Sender: TObject);

private { Private declarations } public { Public declarations }

end;

var Form1: TForm1; TempNo ,TempLogic,TempOperasi,TempSave:string; implementation

{$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if hasil.Caption='0' then hasil.Caption:=''; if Hasil.Caption<>' ' then if TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin if TempOperasi<>'' then Hasil.Caption:='0' else if Hasil.Caption='0' then Hasil.Caption:='0' else begin Hasil.Caption:=Hasil.Caption+'0'; TempLogic:='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 TempLogic='0' then begin TempLogic:='2'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>' ' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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 TempLogic='0' then begin TempLogic:='1'; if TempOperasi<>'' 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

TempOperasi:=''; if (hasil.Caption<>'') then if TempLogic='0' then TempOperasi:='-' else if (TempOperasi='') then begin TempOperasi:='-'; TempLogic:='0'; TempNo :=hasil.Caption; end else begin if TempOperasi='+' then hasil.Caption:=floattostr(strtofloat(TempNo )+strtofloat(hasil.Caption)); if TempOperasi='-' then hasil.Caption:=floattostr(strtofloat(TempNo )-strtofloat(hasil.Caption)); if TempOperasi='x' then hasil.Caption:=floattostr(strtofloat(TempNo )*strtofloat(hasil.Caption)); if TempOperasi='/' then hasil.Caption:=floattostr(strtofloat(TempNo )/strtofloat(hasil.Caption)); if TempOperasi='mod' then hasil.Caption:=inttostr(strtoint(TempNo ) mod strtoint(hasil.Caption)); if TempOperasi='div' then hasil.Caption:=inttostr(strtoint(TempNo )div strtoint(hasil.Caption)); if TempOperasi='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(TempNo )))); TempNo :=hasil.Caption; TempOperasi:='-'; TempLogic:='0'; end; end;

procedure TForm1.Button24Click(Sender: TObject);

begin if TempOperasi='+' then hasil.Caption:=floattostr(strtofloat(TempNo )+strtofloat(hasil.Caption)); if TempOperasi='-' then hasil.Caption:=floattostr(strtofloat(TempNo )-strtofloat(hasil.Caption)); if TempOperasi='x' then hasil.Caption:=floattostr(strtofloat(TempNo )*strtofloat(hasil.Caption)); if TempOperasi='/' then hasil.Caption:=floattostr(strtofloat(TempNo )/strtofloat(hasil.Caption)); TempNo :=hasil.Caption; TempLogic:='0'; end;

procedure TForm1.Button27Click(Sender: TObject); begin hasil.Caption:='0'; TempLogic:=''; TempNo :=''; TempOperasi:=''; end; procedure TForm1.Button18Click(Sender: TObject); begin if hasil.Caption<>'' then hasil.Caption:=hasil.Caption + ','; end;

procedure TForm1.Button15Click(Sender: TObject);

begin TempOperasi:=''; if (hasil.Caption<>'') then if TempLogic='0' then TempOperasi:='+' else if (TempOperasi='') then begin TempOperasi:='+'; TempLogic:='0'; TempNo :=hasil.Caption; end else begin if TempOperasi='+' then hasil.Caption:=floattostr(strtofloat(TempNo )+strtofloat(hasil.Caption)); if TempOperasi='-' then hasil.Caption:=floattostr(strtofloat(TempNo )-strtofloat(hasil.Caption)); if TempOperasi='x' then hasil.Caption:=floattostr(strtofloat(TempNo )*strtofloat(hasil.Caption)); if TempOperasi='/' then hasil.Caption:=floattostr(strtofloat(TempNo )/strtofloat(hasil.Caption)); if TempOperasi='mod' then hasil.Caption:=inttostr(strtoint(TempNo ) mod strtoint(hasil.Caption)); if TempOperasi='div' then hasil.Caption:=inttostr(strtoint(TempNo )div strtoint(hasil.Caption)); if TempOperasi='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(TempNo )))); TempNo :=hasil.Caption; TempOperasi:='+'; TempLogic:='0'; end; end;

procedure TForm1.Button29Click(Sender: TObject); begin TempOperasi:=''; if (hasil.Caption<>'') then if TempLogic='0' then TempOperasi:='x' else if (TempOperasi='') then begin TempOperasi:='x'; TempLogic:='0'; TempNo :=hasil.Caption; end else begin if TempOperasi='+' then hasil.Caption:=floattostr(strtofloat(TempNo )+strtofloat(hasil.Caption)); if TempOperasi='-' then hasil.Caption:=floattostr(strtofloat(TempNo )-strtofloat(hasil.Caption)); if TempOperasi='x' then hasil.Caption:=floattostr(strtofloat(TempNo )*strtofloat(hasil.Caption)); if TempOperasi='/' then hasil.Caption:=floattostr(strtofloat(TempNo )/strtofloat(hasil.Caption)); if TempOperasi='mod' then hasil.Caption:=inttostr(strtoint(TempNo ) mod strtoint(hasil.Caption)); if TempOperasi='div' then hasil.Caption:=inttostr(strtoint(TempNo )div strtoint(hasil.Caption)); if TempOperasi='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(TempNo )))); TempNo :=hasil.Caption; TempOperasi:='x'; TempLogic:='0';

end; end;

procedure TForm1.Button23Click(Sender: TObject); begin TempOperasi:=''; if (hasil.Caption<>'') then if TempLogic='0' then TempOperasi:='/' else if (TempOperasi='') then begin TempOperasi:='/'; TempLogic:='0'; TempNo :=hasil.Caption; end else begin if TempOperasi='+' then hasil.Caption:=floattostr(strtofloat(TempNo )+strtofloat(hasil.Caption)); if TempOperasi='-' then hasil.Caption:=floattostr(strtofloat(TempNo )-strtofloat(hasil.Caption)); if TempOperasi='x' then hasil.Caption:=floattostr(strtofloat(TempNo )*strtofloat(hasil.Caption)); if TempOperasi='/' then hasil.Caption:=floattostr(strtofloat(TempNo )/strtofloat(hasil.Caption)); if TempOperasi='mod' then hasil.Caption:=inttostr(strtoint(TempNo ) mod strtoint(hasil.Caption)); if TempOperasi='div' then hasil.Caption:=inttostr(strtoint(TempNo )div strtoint(hasil.Caption)); if TempOperasi='^' then hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(TempNo )))); TempNo :=hasil.Caption;

TempOperasi:='/'; TempLogic:='0'; end; end;

procedure TForm1.Button19Click(Sender: TObject); begin if hasil.Caption<>'' then hasil.Caption:=floattostr(sqrt(strtofloat(hasil.Caption))); 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));

TempLogic :='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)); TempLogic :='0'; end; end;

procedure TForm1.Button20Click(Sender: TObject); begin hasil.Caption:=TempSave; end;

procedure TForm1.Button21Click(Sender: TObject); begin TempSave:=''; end;

procedure TForm1.Button22Click(Sender: TObject); begin TempSave:=hasil.Caption; 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); begin Close; end;

procedure TForm1.Button14Click(Sender: TObject); var angka:real; begin angka:=StrToFloat(hasil.Caption); angka:=ln(10)/ln(angka); hasil.Caption:=FloatToStr(angka); end;

procedure TForm1.Button17Click(Sender: TObject); var pangkat: real; begin pangkat:=StrToFloat(hasil.Caption); pangkat:=sqr(pangkat); hasil.Caption:=FloatToStr(pangkat) end;

procedure TForm1.Button16Click(Sender: TObject); var angka:real; begin angka:=StrToFloat(hasil.Caption); angka:=angka/100; hasil.Caption:=FloatToStr(angka); end;

end.

Вам также может понравиться