1. Buat seperti gambar di bawah ini:
2. Tulis script dibawah ini :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: 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 FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,b,c:double;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowMessage('AYO BELAJAR MENGHITUNG');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a+b;
Edit3.Text :=floattostr(c);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a-b;
Edit3.Text :=floattostr(c);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a*b;
Edit3.Text :=floattostr(c);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a/b;
Edit3.Text :=floattostr(c);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit1.SetFocus;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
ShowMessage(' "Anda Yakin Akan Keluar" ');
ShowMessage('Terima Kasih ! "Belajar menghitung yang rajin yaaaa!" ');
Application.Terminate;
//close;
end;
end.
3. SELESAI.
Silahkan mencoba..............!
by : KHAFIDZUN FADLI
Tidak ada komentar:
Posting Komentar