unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
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;
Label1: TLabel;
Button17: TButton;
Button18: TButton;
procedure Button1Click(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 Button10Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
OP : char;
hasil : real;
nilai : real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:= Edit1.Text+Button1.Caption;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button2.Caption;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button3.Caption;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button4.Caption;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button5.Caption;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button6.Caption;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text + Button7.Caption;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text+Button8.Caption;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text + Button9.Caption;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text + Button10.Caption;
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
Edit1.Text := '';
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
Edit1.Text := Edit1.Text + '.';
end;
procedure TForm1.Button17Click(Sender: TObject);
begin
if OP ='*' THEN
begin
hasil := nilai * StrToFloat(Edit1.Text);
end
else if OP ='/' THEN
begin
hasil := nilai / StrToFloat(Edit1.Text);
end
else if OP ='+' THEN
begin
hasil := nilai + StrToFloat(Edit1.Text);
end
else if OP ='-' THEN
begin
hasil := nilai - StrToFloat(Edit1.Text);
end;
Edit1.Text := FloatToStr(hasil);
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
OP := '*';
nilai := StrToFloat(Edit1.Text);
Edit1.Text := '';
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
OP := '/';
nilai := StrToFloat(Edit1.Text);
Edit1.Text := '';
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
OP := '+';
nilai := StrToFloat(Edit1.Text);
Edit1.Text := '';
end;
procedure TForm1.Button15Click(Sender: TObject);
begin
OP := '-';
nilai := StrToFloat(Edit1.Text);
Edit1.Text := '';
end;
procedure TForm1.Button18Click(Sender: TObject);
var
kar : integer;
begin
kar := length (Edit1.Text);
if Edit1.Text ='' then
Edit1.Text:=''
else if kar = 1 then
Edit1.Text:=''
else
Edit1.Text := copy(Edit1.Text,1,kar-1);
end;
end.
Tidak ada komentar:
Posting Komentar