Thursday, 1 December 2011

Program Kalkulator Sederhana - Delphi

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Bil_1: TEdit;
Bil_2: TEdit;
Jml: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Tambah: TButton;
Kurang: TButton;
Bagi: TButton;
Kali: TButton;
mod1: TButton;
div1: TButton;
Button1: TButton;
Label4: TLabel;
Button2: TButton;
procedure TambahClick(Sender: TObject);
procedure KurangClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BagiClick(Sender: TObject);
procedure KaliClick(Sender: TObject);
procedure div1Click(Sender: TObject);
procedure mod1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.TambahClick(Sender: TObject);
var EdJumlah : integer;
begin
EdJumlah := StrToInt(Bil_1.Text)+StrToInt(Bil_2.Text);
jml.Text := IntToStr(EdJumlah);
end;

procedure TForm1.KurangClick(Sender: TObject);
var edjumlah : integer;
begin
EdJumlah := StrToInt(Bil_1.Text)-StrToInt(Bil_2.Text);
jml.Text := IntToStr(EdJumlah);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if (application.MessageBox('Anda yakin keluar dari program','Information',mb_yesno)=idyes) then
close;
end;

procedure TForm1.BagiClick(Sender: TObject);
var edjumlah : real;
bil1,bil2 : real;
begin
bil1 := StrToFloat(Bil_1.Text);
bil2 := StrToFloat(bil_2.Text);
EdJumlah := bil1/bil2;
jml.Text := FloatToStr(EdJumlah);
end;

procedure TForm1.KaliClick(Sender: TObject);
var edjumlah : integer;
begin
EdJumlah := StrToInt(Bil_1.Text)*StrToInt(Bil_2.Text);
jml.Text := IntToStr(EdJumlah);
end;

procedure TForm1.div1Click(Sender: TObject);
var edjumlah : integer;
begin
EdJumlah := StrToInt(Bil_1.Text) div StrToInt(Bil_2.Text);
jml.Text := IntToStr(EdJumlah);
end;

procedure TForm1.mod1Click(Sender: TObject);
var edjumlah : integer;
begin
EdJumlah := StrToInt(Bil_1.Text) mod StrToInt(Bil_2.Text);
jml.Text := IntToStr(EdJumlah);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
bil_1.Clear;
bil_2.Clear;
Jml.Clear;
end;

end.

No comments: