Pertemuan 2 Logika Percabangan
I.
Deskripsi
Program
Program ini dibuat dengan Delphi7 yang digunakan untuk mengetahui gaji
bersih pegawai dari gaji yang diinputkan. Menggunakan 5 label, 4 edit dan program
ini hanya menggunakan 3 button, yaitu : button untuk menampilkan total gaji
menurut status pegawainya, button untuk mrngisi data lagi dan button untuk
keluar.
Coding
Program
Nama Komponen
|
Event
|
Perintah
|
Button2
|
OnClick
|
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
RadioButton1.Checked:=false;
RadioButton2.Checked:=false;
ComboBox1.ItemIndex:=-1;
end;
|
ComboBox1
|
OnClick
|
procedure TForm1.ComboBox1Click(Sender:
TObject);
begin
if combobox1.text='Direktur'then
edit2.Text:='5000000'
else
if
combobox1.text='Manager'then
edit2.Text:='2000000'
else
if
combobox1.text='Karyawan'then
edit2.Text:='1000000'
else
edit2.Text:='0'
end;
|
RadioButton1
|
OnClick
|
procedure TForm1.RadioButton1Click(Sender:
TObject);
var
a,hasil:real;
begin
if RadioButton1.Checked=true
then
a:=strtofloat(edit2.Text);
hasil:=a*0.3;
edit3.Text:=floattostr(hasil)
end;
|
RadioButton2
|
OnClick
|
procedure TForm1.RadioButton2Click(Sender:
TObject);
var
a,hasil:real;
begin
if RadioButton2.Checked=true then
a:=strtofloat(edit2.Text);
hasil:=a*0.1;
edit3.Text:=floattostr(hasil)
end;
|
RadioButton1
|
OnClick
|
procedure TForm1.Button1Click(Sender:
TObject);
var a,b,c:real;
begin
a:=strtofloat(edit2.Text);
b:=strtofloat(edit3.text);
c:=a+b;
edit4.Text:=floattostr(c);
end;
|
Button3
|
OnClick
|
procedure TForm1.Button3Click(Sender:
TObject);
begin
close;
end;
end.
|
Komentar
Posting Komentar