PENERAPAN PEMROGRAMAN DELPHI (ARRAY) DALAM INPUT DATA MAHASISWA DAN PERMASALAHAN MATEMATIKA Diajukan Untuk Memenuhi Tugas Program Komputer Dosen : Deddy Sofyan, M.Pd. Disusun oleh: Supian [ 09512038 ] Prog. Studi : Pendidikan Matematika S-I 1
PENERAPAN PEMROGRAMAN DELPHI (ARRAY)
DALAM INPUT DATA MAHASISWA DAN
PERMASALAHAN MATEMATIKA
Diajukan Untuk Memenuhi Tugas Program Komputer
Dosen : Deddy Sofyan, M.Pd.
Disusun oleh:
Supian
[ 09512038 ]
Prog. Studi : Pendidikan Matematika S-I
SEKOLAH TINGGI KEGURUAN DAN ILMU
PENDIDIKAN (STKIP)
GARUT
1
DAFTAR MENU
1. FORM COVER
Form Cover di atas adalah sebagai jembatan untuk menghubungkan
ke form selanjutnya yaitu Form Password yang nantinya akan terhubung
dengan Form Menu. Adapun untuk membuat form tersebut kita harus
menyisipkan beberapa komponen ke dalam form tersebut, diantaranya
sebagai berikut:
2
C o v e r
L o g In
M e n u
A u d io P la y e rs
D a ta M a h a s isw
a
P e rm a sa lah a n
M a te m a ti ka
Kalkulator
Deret
Aritmatika
Geometri
Volume &
Luas Permukaan
Kubus
Balok
Bola
Persamaan Kuadrat
Faktor ial
Konvers i Suhu
E x it
Komp
.Caption Name
Visibl
e
Label1 Aplikasi Array Label1 false
Label2 Dan Label2 false
Label3 Permasalahan Dalam Matematika Label3 false
Label4 Untuk Memenuhi Tugas Program Komputer Label4 false
Label5 Disusun Oleh : Label5 false
Label6 Supian [09512038] Label6 false
Label7Sekolah Tinggi Keguruan dan Ilmu Pendidikan
(STKIP)Label7 false
Label8 Garut Label8 false
Label9 2010/2011 Label9 false
Label1
0Label10 Label10 false
Label1
1Label11 Label11 false
Timer1 Timer1
Timer2 Timer2
Image
1
ImageStk
ipfalse
Untuk komponen timer1 interval dirubah menjadi 800, sedangkan
untuk timer2 tetap 1000. Untuk Formnya juga Caption dan Namenya
dirbah menjadi Forn Cover dan FormCover. Adapun untuk program
listingnya adalah sebagai berikut:
Var
FormCover:
TFormCover;
a:integer;
implementatio
n
uses
U_Password;
{$R *.dfm}
3
procedure TFormCover.Timer1Timer(Sender: TObject);
begin
Label10.Caption:='Pukul '+Timetostr(Now);
Label11.Caption:='Tanggal '+Datetostr(Now);
if ProgressBarCover.Position = 100 then
begin
Timer1.Enabled:=False; FormCover.Hide;
formPassword.show;
end
else
begin
ProgressBarCover.Position :=ProgressBarCover.Position + 5;
end;
end;
procedure TFormCover.Timer2Timer(Sender: TObject);
begin
a:=a+1;
if a=1 then
label1.visible:=true;
if a=2 then
label2.Visible:=true;
if a=3 then
label3.Visible:=true;
if a=4 then
label4.Visible:=true;
if a=5 then
label5.Visible:=true;
if a=6 then
label6.Visible:=true;
if a=7 then
imageStkip.Visible:=
true;
if a=8 then
label7.Visible:=true;
if a=9 then
label8.Visible:=true;
if a=10 then
label9.Visible:=true;
if a=11 then
begin
label1.visible:=false;
label2.visible:=false;
label3.visible:=false;
label4.visible:=false;
label5.visible:=false;
label6.visible:=false;
imageStkip.visible:=
false;
label7.visible:=false;
label8.visible:=false;
label9.visible:=false;
a:=0;
end;
end;
4
2. FORM PASSWORD
Pada Form Password ini kita diperintahkan untuk memasukan
password atau PIN, apabila kita salah memasukan PIN tersebut maka akan
ada tampilan seperti gambar di atas, dan secara otomatis kita tidak bisa
ke Form Menu.Adapun untuk membuat Form Password tersebut adalah
sebagai berikut, kita harus menyisipkan komponen label1, label2, edit1,
edit2, bitbtn1, dan bitbtn2.
Label1 Label2
Properti
esValue
Caption Confirm PIN
Name Label2
Edit1 Edit2
Bitbtn1Bitbtn2
5
Propertie
sValue
CaptionMasukan
PIN
Name Label1
Propertie
sValue
Caption Kosongkan
Name Edit1
PasswordC
har*
Propertie
sValue
Caption Kosongkan
Name Edit2
PasswordC
har*
Propertie
sValue
Caption OK
Name Bitbtn1
Kind bkOK
Propertie
sValue
Caption Cancel
Name Bitbtn2
Kind bkCancel
Setelah semua komponen di masukan kedalam form lalu masukan
program listing seperti berikit:
procedure TFormPassword.BitBtn1Click(Sender: TObject);
begin
if Edit1.Text=Edit2.Text then
FormMenu.show
else
Begin
messagedlg('Password Anda Tidak
Cocok'+chr(10)+chr(13)+'Silahka
n Untuk Mengulanggi
Kembali'+chr(10)+chr(13)+'Atau
Silahkan Keluar...Karena Hanya
Yang Tau PIN yang Dapat Masuk',
mtinformation,[mbOK],0);
Edit1.SetFocus;
end;
procedure TFormPassword.BitBtn2Click(Sender: TObject);
begin application.Terminat
e;
end;
3. FORM MENU
Pada Form Menu ini kita bisa memilih program mana yang akan kita
jalankan, ada beberapa pilihan dalam Form Menu ini diantaranya ada
menu Audio Players, Input Data Mahasiswa, Permasalahan Matematika,
dan selesai yang fungsinya untuk menutup aplikasi. Untuk komponennya
kita harus memasukan:
Komp.Capti
onName
Visibl
e Komp.
Capti
onName
Visibl
e
Label
1P
Label
1
FALS
E
Label
5O
Label
5
FALS
E
Label
2E
Label
2
FALS
E
Label
6G
Label
6
FALS
E
Label
3M
Label
3
FALS
E
Label
7R
Label
7
FALS
E
Label
4R
Label
4
FALS
E
Label
8A
Label
8
FALS
E
6
Komp. Capti
on
Name Visibl
e
Komp. Capti
on
Name Visibl
e
Label
9M
Label
9
FALS
E
Label
16H
Label
16
FALS
E
Label
10A
Label
10
FALS
E
Label
17I
Label
17
FALS
E
Label
11N
Label
11
FALS
E
Image
1
Image
1
FALS
E
Label
12D
Label
12
FALS
E
Image
2
Image
2
FALS
E
Label
13E
Label
13
FALS
E
Image
3
Image
3
FALS
E
Label
14L
Label
14
FALS
E
Image
4
Image
4
FALS
E
Label
15P
Label
15
FALS
E
Image
5
Image
5
FALS
E
Setelah itu sisipkan MainMenu1 dan Timer1, Double Click pada
MainMenu1kemudian masukan menu-menu yang di
butuhkan,seperti gambar dibawah ini:
7
Gambar di bawah ini merupakan Form Menu Yang sudah di runing
Untuk prigram listing Form Menu adalah sebagai berikut:
procedure TFormMenu.Timer1Timer(Sender: TObject);
begin
a:=a+1;
if a=1 then
label1.visible:=true;
if a=2 then
label2.Visible:=true;
if a=3 then
label3.Visible:=true;
if a=4 then
label4.Visible:=true;
if a=5 then
label5.Visible:=true;
if a=6 then
label6.Visible:=true;
if a=8 then
label7.Visible:=true;
if a=9 then
label8.Visible:=true;
if a=10 then
label9.Visible:=true;
if a=11 then
label10.Visible:=true
;
if a=12 then
label11.Visible:=true
;
if a=13 then
label12.Visible:=true
;
if a=14 then
label13.Visible:=true
;
if a=15 then
label14.Visible:=true
;
if a=16 then
label15.Visible:=true
;
if a=17 then
label16.Visible:=true
;
if a=18 then
label17.Visible:=true
;
8
if a=19 then
image1.Visible:=true
;
if a=20 then
image2.Visible:=true
;
if a=21 then
image3.Visible:=true
;
if a=22 then
image4.Visible:=true
;
if a=23 then
image5.Visible:=true
;
if a=24 then
begin
label1.visible:=false;
label2.visible:=false;
label3.visible:=false;
label4.visible:=false;
label5.visible:=false;
label6.visible:=false;
label7.visible:=false;
label8.visible:=false;
label9.visible:=false;
label10.visible:=fals
e;
label11.visible:=fals
e;
label12.visible:=fals
e;
label13.visible:=fals
e;
label14.visible:=fals
e;
label15.visible:=fals
e;
label16.visible:=fals
e;
label17.visible:=fals
e;
image1.Visible:=fals
e;
image2.Visible:=fals
e;
image3.Visible:=fals
e;
image4.Visible:=fals
e;
image5.Visible:=fals
e;
a:=0;
end;
Lalu double click MainMenu1 dan double click lagi pada menu yang
sudah di tuliskan pada bagian MainMenu tersebut kemudian tuliskan
listing program di bawah ini,
procedure TFormMenu.WinamFiant1Click(Sender: TObject);
begin
FormAudioPlayers.show;
end;
procedure TFormMenu.InputData1Click(Sender: TObject);
begin
FormDataMahasiswa.show;
end;
9
procedure TFormMenu.Kalkulator1Click(Sender: TObject);
begin
FormKalkulator.Show;
end;
procedure TFormMenu.Aritmatika1Click(Sender: TObject);
begin
FormDrtAritmatika.Show;
end;
procedure TFormMenu.Geometri1Click(Sender: TObject);
begin
FormDrtGeometri.show;
end;
procedure TFormMenu.Kubus1Click(Sender: TObject);
begin
FormVLpKubus.show;
end;
procedure TFormMenu.Balok1Click(Sender: TObject);
begin
FormVLpBalok.show;
end;
procedure TFormMenu.Bola1Click(Sender: TObject);
begin
FormVLpBola.Show;
end;
procedure TFormMenu.P1Click(Sender: TObject);
begin
FormFaktorial.Show;
end;
procedure TFormMenu.Faktorial1Click(Sender: TObject);
begin
FormPersKuadrat.show;
end;
10
procedure TFormMenu.KonversiSuhu1Click(Sender: TObject);
begin
FormKonversiSuhu.show;
end;
procedure TFormMenu.Exit1Click(Sender: TObject);
begin
FormExit.show;
end;
4. FORM AUDIO PLAYERS
Komponen-komponen pada Form Audio
Players
procedure
TFormAudioPlayers.Button1Click(Send
er: TObject);
begin
OpenDialog1.Execute;
VideoPlayer.FileName:=OpenDialog1.File
Name;
VideoPlayer.Open;
Timer2.Enabled:=true;
end;
procedure
TFormAudioPlayers.FileListBox1Click(
Sender: TObject);
begin
AudioPlayer.FileName:=FileListBox1.File
Name;
AudioPlayer.Open;
Label3.Caption:=FileListBox1.FileName;
AudioBar.Max:=AudioPlayer.Length;
end;
11
procedure
TFormAudioPlayers.FileListBox1DblCli
ck(Sender: TObject);
begin
AudioPlayer.FileName:=FileListbox1.File
Name;
AudioPlayer.Open;
Label3.Caption:=FileListBox1.FileName;
AudioBar.Max:=AudioPlayer.Length;
AudioPlayer.Play;
AudioPlayer.Next;
AudioPlayer.Previous;
end;
procedure
TFormAudioPlayers.SpeedButton1Click
(Sender: TObject);
begin
Paudio.Visible:=SpeedButton1.Down;
end;
procedure
TFormAudioPlayers.SpeedButton2Click
(Sender: TObject);
begin
vaudio.Visible:=SpeedButton1.Down;
end;
procedure
TFormAudioPlayers.Timer1Timer(Send
er: TObject);
begin
if label3.left<-label3.Width
thenlabel3.Left:=Panel2.Width
else
label3.Left:=label3.Left-1;
AudioBar.Position:=AudioPlayer.Position;
end;
procedure
TFormAudioPlayers.Timer2Timer(Send
er: TObject);
begin
if image1.left<-image1.Width
thenimage1.Left:=vaudio.Width
else
image1.Left:=label3.Left-1;
end;
procedure
TFormAudioPlayers.Timer3Timer(Send
er: TObject);
begin
Videobar.Max:=VideoPlayer.Length;
Videobar.Position:=VideoPlayer.Position;
if label5.left<-label5.Width
thenlabel5.Left:=Panel3.Width
else
label5.Left:=label5.Left-1;
VideoBar.Position:=VideoPlayer.Position;
end;
12
5. FORM INPUT DATA MAHASISWA
Komponen Properties
Bittbtn1 Caption Input Data
Bittbtn2Caption Retry
Kind bkRetry
Bittbtn3Caption Close
Kind bkClose
GroupBox1 Caption Input Data Mahasiswa
GroupBox2 Caption Output Data Mahasiswa
Listbox1
Timer1
Label1 Caption Program Input Data Mahasiswaprocedure TFormDataMahasiswa.BitBtn1Click(Sender: TObject);
begin
listbox1.Items.Clear;
s:=inputbox('Loop','J
umlah Perulangan
Data','');
p:=strtoint(s);
stringgrid1.Cells[0,0]
:='No';
stringgrid1.Cells[1,0]
:='Nama';
stringgrid1.Cells[2,0]
:='Nim';
stringgrid1.Cells[3,0]
:='Jenis Kelamin';
13
stringgrid1.Cells[4,0]
:='Jurusan';
stringgrid1.Cells[5,0]
:='No Telephone';
stringgrid1.Cells[6,0]
:='Alamat';
for i := 1 to p do
begin
No[i]:=inputbox('ID','
No','');
Nama[i]:=inputbox('I
D','Nama','');
Nim[i]:=inputbox('ID
','Nim','');
JenisKelamin[i]:=inp
utbox('ID','Jenis
Kelamin','');
Jurusan[i]:=inputbox
('ID','Jurusan','');
NoTelp[i]:=inputbox(
'ID','No Telp','');
Alamat[i]:=inputbox(
'ID','Alamat','');
listbox1.Items.Add('
No'+chr(1)+chr(1)+
chr(1)+chr(1)+chr(1
)+' : '+inttostr(i));
listbox1.Items.Add('
Nama'+chr(1)+chr(1
)+chr(1)+chr(1)+' :
'+nama[i]);
listbox1.Items.Add('
Nim'+chr(1)+chr(1)
+chr(1)+chr(1)+chr(
1)+' : '+Nim[i]);
listbox1.Items.Add('J
enis
Kelamin'+chr(1)+' :
'+JenisKelamin[i]);
listbox1.Items.Add('J
urusan'+chr(1)+chr(
1)+chr(1)+' :
'+Jurusan[i]);
listbox1.Items.Add('
No
Telp'+chr(1)+chr(1)
+chr(1)+' :
'+NoTelp[i]);
listbox1.Items.Add('
Alamat'+chr(1)+chr(
1)+chr(1)+chr(1)+' :
'+Alamat[i])
listbox1.Items.Add('
============
============
============
============
============
============
=====');
stringgrid1.Cells[0,i]:
=No[i];
stringgrid1.Cells[1,i]:
=Nama[i];
stringgrid1.Cells[2,i]:
=Nim[i];
stringgrid1.Cells[3,i]:
=JenisKelamin[i];
stringgrid1.Cells[4,i]:
=Jurusan[i];
stringgrid1.Cells[5,i]:
=NoTelp[i];
stringgrid1.Cells[6,i]:
=Alamat[i];
end;
procedure TFormDataMahasiswa.BitBtn2Click(Sender: TObject);
begin
listbox1.Clear;
stringgrid1.Cells[0,0]
:='';
stringgrid1.Cells[0,1]
:='';
stringgrid1.Cells[0,2]
:='';
stringgrid1.Cells[0,3]
:='';
stringgrid1.Cells[0,4]
:='';
stringgrid1.Cells[0,5]
:='';
14
stringgrid1.Cells[0,6]
:='';
stringgrid1.Cells[0,7]
:='';
stringgrid1.Cells[1,0]
:='';
stringgrid1.Cells[1,1]
:='';
stringgrid1.Cells[1,2]
:='';
stringgrid1.Cells[1,3]
:='';
stringgrid1.Cells[1,4]
:='';
stringgrid1.Cells[1,5]
:='';
stringgrid1.Cells[1,6]
:='';
stringgrid1.Cells[1,7]
:='';
stringgrid1.Cells[2,0]
:='';
stringgrid1.Cells[2,1]
:='';
stringgrid1.Cells[2,2]
:='';
stringgrid1.Cells[2,3]
:='';
stringgrid1.Cells[2,4]
:='';
stringgrid1.Cells[2,5]
:='';
stringgrid1.Cells[2,6]
:='';
stringgrid1.Cells[2,7]
:='';
stringgrid1.Cells[3,0]
:='';
stringgrid1.Cells[3,1]
:='';
stringgrid1.Cells[3,2]
:='';
stringgrid1.Cells[3,3]
:='';
stringgrid1.Cells[3,4]
:='';
stringgrid1.Cells[3,5]
:='';
stringgrid1.Cells[3,6]
:='';
stringgrid1.Cells[3,7]
:='';
stringgrid1.Cells[4,0]
:='';
stringgrid1.Cells[4,1]
:='';
stringgrid1.Cells[4,2]
:='';
stringgrid1.Cells[4,3]
:='';
stringgrid1.Cells[4,4]
:='';
stringgrid1.Cells[4,5]
:='';
stringgrid1.Cells[4,6]
:='';
stringgrid1.Cells[4,7]
:='';
stringgrid1.Cells[5,0]
:='';
stringgrid1.Cells[5,1]
:='';
stringgrid1.Cells[5,2]
:='';
stringgrid1.Cells[5,3]
:='';
stringgrid1.Cells[5,4]
:='';
stringgrid1.Cells[5,5]
:='';
stringgrid1.Cells[5,6]
:='';
stringgrid1.Cells[5,7]
:='';
stringgrid1.Cells[6,0]
:='';
stringgrid1.Cells[6,1]
:='';
stringgrid1.Cells[6,2]
:='';
stringgrid1.Cells[6,3]
:='';
stringgrid1.Cells[6,4]
:='';
stringgrid1.Cells[6,5]
:='';
15
stringgrid1.Cells[6,6]
:='';
stringgrid1.Cells[6,7]
:='';
end;
procedure TFormDataMahasiswa.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure TFormDataMahasiswa.Timer1Timer(Sender: TObject);
begin
if label1.left<-label1.Width then label1.Left:=Panel1.Width
else label1.Left:=label1.Left-1;
end;
6. KALKULATOR
Sisipkan komponen-komponen berikiut:
Butto
n
Proper
tyNilai
Butto
n
Proper
tyNilai
1
Captio
n0
13
Captio
n+
Name Button0 Name ButtonPlus
16
2
Captio
n1
14
Captio
n-
Name Button1 Name ButtonMin
3
Captio
n2
15
Captio
nx
Name Button2 Name ButtonKali
4
Captio
n3
16
Captio
n/
Name Button3 Name ButtonBagi
5
Captio
n4
17
Captio
ndiv
Name Button4 Name ButtonDiv
6
Captio
n5
18
Captio
nmod
Name Button5 Name ButtonMod
7
Captio
n6
19
Captio
n=
Name Button6 NameButtonResu
lt
8
Captio
n7
20
Captio
nsqr
Name Button7 NameButtonKuad
rat
9
Captio
n8
21
Captio
nsqrt
Name Button8 Name ButtonAkar
10
Captio
n9
22
Captio
nx^y
Name Button9 NameButtonPang
kat
17
11
Captio
n.
23
Captio
nsin
NameButtonPoi
ntName ButtonSin
12Captio
n+/- 24
Captio
ncos
NameButtonNo
tName ButtonCos
Butt
on
Prope
rtyNilai Button
Prope
rtyNilai
25
Capti
ontan
32
Capti
onn!
NameButtonT
anName
Button
Fak
26
Capti
onln
33
Capti
onoff
NameButtonL
nName
Button
Off
27
Capti
onlog
34
Capti
onon
NameButtonL
ogName
Button
On
28
Capti
on1/x
RadioBut
ton
Prope
rtyNilai
NameButtonP
er1
Capti
onDeg
29
Capti
onmr Name RbDeg
NameButton
Mr
2 Capti
onRad
30 Capti m+ Name RbRad
18
on
NameButton
M3
Capti
onGrads
31
Capti
onpi Name
RbGrad
s
NameButtonP
hi
Pada component palette tab Win32, masukkan komponen
StatusBar ke dalam Form1, fungsinya untuk mempercantik tampilan
interface program (sebagai footer dari form). Kemudian masukan listing
program berikut:
var
FormKalkulator: TFormKalkulator;
MemAngka,MemLogic,MemOperator,MemSimpan:string;
implementation
uses math;
{$R *.dfm}
procedure TFormKalkulator.Butto5Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then memo1.Text:='5' else
memo1.text:='5';
end else
memo1.Text:=memo1.Text+'5'; end;
procedure TFormKalkulator.Button0Click(Sender: TObject);
Begin
if memo1.text<>'' then
if MemLogic='0' then
begin
if MemOperator<>'' then
memo1.Text:='0' else
19
if memo1.text='0' then
memo1.text:='0' else
begin
memo1.Text:=memo1.Text+'0';
MemLogic:='1';
end;
end
else
memo1.Text:=memo1.Text+'0';
end;
procedure TFormKalkulator.Button1Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='1' else
memo1.text:='1';
end
else
memo1.Text:=memo1.Text+'1';
end;
procedure TFormKalkulator.Button2Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='2'
else
memo1.text:='2';
end
else
memo1.Text:=memo1.Text+'2';
end;
procedure TFormKalkulator.Button3Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='3' else
memo1.text:='3';
end
else
memo1.Text:=memo1.Text+'3';
end;
procedure TFormKalkulator.Button4Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
20
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='4' else
memo1.text:='4';
end
else
memo1.Text:=memo1.Text+'4';
end;
procedure TFormKalkulator.Button6Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='6' else
memo1.text:='6' ;
end
else
memo1.Text:=memo1.Text+'6';
end;
procedure TFormKalkulator.Button7Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='7' else
memo1.text:='7' ;
end
else
memo1.Text:=memo1.Text+'7';
end;
procedure TFormKalkulator.Button8Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='8' else
memo1.text:='8';
end
else
memo1.Text:=memo1.Text+'8';
end;
procedure TFormKalkulator.Button9Click(Sender: TObject);
begin
if memo1.text<>'' then
if MemLogic='0' then
begin
21
MemLogic:='1';
if MemOperator<>'' then
memo1.Text:='9' else
memo1.text:='9';
end
else
memo1.Text:=memo1.Text+'9';
end;
procedure TFormKalkulator.ButtonAkarClick(Sender: TObject);
begin
if memo1.text<>'' then
memo1.Text:=floattostr(sqrt(strtofloat(memo1.Text)));
end;
procedure TFormKalkulator.ButtonBagiClick(Sender: TObject);
begin
if (memo1.text<>'') then
if MemLogic='0' then
MemOperator:='/' else
if (MemOperator='') then
begin
MemOperator:='/';
MemLogic:='0';
MemAngka:=memo1.Text;
End else begin
if MemOperator='+' then
memo1.Text:=floattostr(strtofloat
(MemAngka)
+strtofloat(memo1.Text));
if MemOperator='-' then
memo1.Text:=floattostr(strtofloat
(MemAngka)-
strtofloat(memo1.Text));
if MemOperator='x' then
memo1.Text:=floattostr(strtofloat
(MemAngka)*strtofloat(memo1.Te
xt));
if MemOperator='/' then
memo1.Text:=floattostr(strtofloat
(MemAngka)/strtofloat(memo1.Te
xt));
if MemOperator='mod' then
memo1.Text:=inttostr(strtoint(Me
mAngka) mod
strtoint(memo1.Text));
if MemOperator='div' then
memo1.Text:=inttostr(strtoint(Me
mAngka)div
strtoint(memo1.Text));
if MemOperator='^' then
memo1.Text:=floattostr(exp(strto
float(memo1.Text)*ln(strtofloat(M
emAngka))));
MemAngka:=memo1.Text;
MemOperator:='/';
MemLogic:='0';
end;
end;
22
procedure TFormKalkulator.ButtonCosClick(Sender: TObject);
var sudut:real;
begin
if memo1.Text<>''
then
begin
sudut:=strtofloat(me
mo1.Text);
if RbDeg.Checked =
true then
sudut:=sudut*pi/180
else
if RbRad.Checked =
true then
sudut:=sudut else
if RbGrads.Checked
= true then
sudut:=sudut*pi/200
;
memo1.Text :=
floattostr(cos(sudut))
;
MemLogic :='0';
end;
end
procedure TFormKalkulator.ButtonDivClick(Sender: TObject);
begin
if (memo1.text<>'')
then
if MemLogic='0'
then
MemOperator:='div'
else
if (MemOperator='')
then
begin
MemOperator:='div';
MemLogic:='0';
MemAngka:=memo1
.Text;end
elsebegin
if MemOperator='+'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)
+strtofloat(memo1.T
ext));
if MemOperator='-'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)-
strtofloat(memo1.Te
xt));
if MemOperator='x'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)*strtofloat(me
mo1.Text));
if MemOperator='/'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)/strtofloat(me
mo1.Text));
if
MemOperator='mod'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a) mod
strtoint(memo1.Text
));
if
MemOperator='div'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a)div
strtoint(memo1.Text
));
if MemOperator='^'
then
memo1.Text:=floatt
ostr(exp(strtofloat(m
23
emo1.Text)*ln(strtofl
oat(MemAngka))));
MemAngka:=memo1
.Text;
MemOperator:='div';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonFakClick(Sender: TObject);
var i,n,fak:integer;
begin
if memo1.Text<>'' then
begin
n :=strtoint(memo1.Text);
fak:=1;
for i:=1 to n-1 do
fak:=fak*n;
memo1.Text:=inttostr(fak);
MemLogic :='0';
end;
end;
procedure TFormKalkulator.ButtonKaliClick(Sender: TObject);
begin
if (memo1.text<>'')
then
if MemLogic='0'
then
MemOperator:='x'
else
if (MemOperator='')
then
begin
MemOperator:='x';
MemLogic:='0';
MemAngka:=memo1
.Text;
end
else
begin
if MemOperator='+'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)
+strtofloat(memo1.T
ext));
if MemOperator='-'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)-
strtofloat(memo1.Te
xt));
if MemOperator='x'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)*strtofloat(me
mo1.Text));
if MemOperator='/'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)/strtofloat(me
mo1.Text));
if
MemOperator='mod'
then
memo1.Text:=inttos
24
tr(strtoint(MemAngk
a) mod
strtoint(memo1.Text
));
if
MemOperator='div'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a)div
strtoint(memo1.Text
));
if MemOperator='^'
then
memo1.Text:=floatt
ostr(exp(strtofloat(m
emo1.Text)*ln(strtofl
oat(MemAngka))));
MemAngka:=memo1
.Text;
MemOperator:='x';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonKuadratClick(Sender: TObject);
begin
if memo1.text<>'' then
memo1.Text:=floattostr(sqr(strtofloat(memo1.Text)));
end;
procedure TFormKalkulator.ButtonLnClick(Sender: TObject);
begin
if (memo1.text<>'') then
memo1.Text := floattostr(ln(strtofloat(memo1.Text)));
end;
procedure TFormKalkulator.ButtonLogClick(Sender: TObject);
begin
if memo1.Text<=inttostr(0) then
memo1.Text :='Error'
else
if (memo1.text<>'') then
memo1.Text :=
floattostr(log10(strtofloat(memo1.
Text)));
end;
procedure TFormKalkulator.ButtonMClick(Sender: TObject);
begin
memo1.Text := MemSimpan ;
end;
procedure TFormKalkulator.ButtonMinClick(Sender: TObject);
begin
if (memo1.text<>'')
then
if MemLogic='0'
then
MemOperator:='-'
else
25
if (MemOperator='')
then
begin
MemOperator:='-';
MemLogic:='0';
MemAngka:=memo1
.Text;
end
else
begin
if MemOperator='+'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)
+strtofloat(memo1.T
ext));
if MemOperator='-'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)-
strtofloat(memo1.Te
xt));
if MemOperator='x'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)*strtofloat(me
mo1.Text));
if MemOperator='/'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)/strtofloat(me
mo1.Text));
if
MemOperator='mod'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a) mod
strtoint(memo1.Text
));
if
MemOperator='div'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a)div
strtoint(memo1.Text
));
if MemOperator='^'
then
memo1.Text:=floatt
ostr(exp(strtofloat(m
emo1.Text)*ln(strtofl
oat(MemAngka))));
MemAngka:=memo1
.Text;
MemOperator:='-';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonModClick(Sender: TObject);
begin
if (memo1.text<>'')
then
if MemLogic='0'
then
MemOperator:='mod
' else
if (MemOperator='')
then
begin
MemOperator:='mod
';
MemLogic:='0';
MemAngka:=memo1
.Text;
end
else
begin
if MemOperator='+'
then
26
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)
+strtofloat(memo1.T
ext));
if MemOperator='-'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)-
strtofloat(memo1.Te
xt));
if MemOperator='x'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)*strtofloat(me
mo1.Text));
if MemOperator='/'
then
memo1.Text:=floatt
ostr(strtofloat(MemA
ngka)/strtofloat(me
mo1.Text));
if
MemOperator='mod'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a) mod
strtoint(memo1.Text
));
if
MemOperator='div'
then
memo1.Text:=inttos
tr(strtoint(MemAngk
a)div
strtoint(memo1.Text
));
if MemOperator='^'
then
memo1.Text:=floatt
ostr(exp(strtofloat(m
emo1.Text)*ln(strtofl
oat(MemAngka))));
MemAngka:=memo1
.Text;
MemOperator:='mod
';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonMrClick(Sender: TObject);
begin
MemSimpan := memo1.Text ; MemLogic := '0';
MemOperator :=''; MemAngka := '0';
end;
procedure TFormKalkulator.ButtonNotClick(Sender: TObject);
begin
if memo1.text<>'' then
memo1.Text:=floattostr(strtofloat(memo1.Text)*(-1));
{mengubah nilai memo1 menjadi positif atau negatif}
end;
27
procedure TFormKalkulator.ButtonoffClick(Sender: TObject);
begin
memo1.clear;
{mengosongkan
tampilan layar
calculator}
MemLogic:='';
MemSimpan :='0';
{menonaktifkan
ketiga radiobutton}
RbDEG.Checked :=f
alse;
RbRAD.Checked :=f
alse;
RbGRADS.Checked:
=fale;
end;
procedure TFormKalkulator.ButtonOnClick(Sender: TObject);
begin
{setting ketika
tombol on ditekan}
Memo1.Text:='0';
{membuat layar
kalkulator berisi
angka 0}
MemLogic:='0';
{merubah nilai
variable MemLogic
menjadi 0}
MemOperator :='';
{mengosongkan
nilai variable
MemOperator}
MemAngka :='0';
{merubah nilai
variable MemAngka
menjadi 0}
{mengaktifkan
kembali ketiga
radiobutton}
RbDEG.Enabled:=tru
e;
RbRAD.Enabled:=tru
e;
RbGRADS.Enabled:=
true;
RbDEG.Checked:=tr
ue; {mengecek
radiobutton RbDeg}
end;
procedure TFormKalkulator.ButtonPangkatClick(Sender: TObject);
begin
if (memo1.text<>'') then
if MemLogic='0' then
MemOperator:='^' else
if (MemOperator='') then
begin
MemOperator:='^';
MemLogic:='0';
MemAngka:=memo1.Text;
end
else
begin
if MemOperator='+' then
memo1.Text:=floattostr(strtofloat
(MemAngka)
+strtofloat(memo1.Text));
if MemOperator='-' then
memo1.Text:=floattostr(strtofloat
(MemAngka)-
strtofloat(memo1.Text));
28
if MemOperator='x' then
memo1.Text:=floattostr(strtofloat
(MemAngka)*strtofloat(memo1.Te
xt));
if MemOperator='/' then
memo1.Text:=floattostr(strtofloat
(MemAngka)/strtofloat(memo1.Te
xt));
if MemOperator='mod' then
memo1.Text:=inttostr(strtoint(Me
mAngka) mod
strtoint(memo1.Text));
if MemOperator='div' then
memo1.Text:=inttostr(strtoint(Me
mAngka)div
strtoint(memo1.Text));
if MemOperator='^' then
memo1.Text:=floattostr(exp(strto
float(memo1.Text)*ln(strtofloat(M
emAngka))));
MemAngka:=memo1.Text;
MemOperator:='^';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonPerClick(Sender: TObject);
begin
if memo1.Text = '0' then memo1.Text:='Error divide zero' else
if memo1.Text<>'' then memo1.Text
:=floattostr(1/strtofloat(memo1.Text));
MemLogic :='0';
end;
procedure TFormKalkulator.ButtonPhiClick(Sender: TObject);
begin
if memo1.Text<>'' then memo1.Text := floattostr(pi);
end;
procedure TFormKalkulator.ButtonPlusClick(Sender: TObject);
begin
if (memo1.text<>'') then
if MemLogic='0' then
MemOperator:='+' else
if (MemOperator='') then
begin
MemOperator:='+';
MemLogic:='0';
MemAngka:=memo1.Text;
end
else
begin
if MemOperator='+' then
memo1.Text:=floattostr(strtofloat
29
(MemAngka)
+strtofloat(memo1.Text));
if MemOperator='-' then
memo1.Text:=floattostr(strtofloat
(MemAngka)-
strtofloat(memo1.Text));
if MemOperator='x' then
memo1.Text:=floattostr(strtofloat
(MemAngka)*strtofloat(memo1.Te
xt));
if MemOperator='/' then
memo1.Text:=floattostr(strtofloat
(MemAngka)/strtofloat(memo1.Te
xt));
if MemOperator='mod' then
memo1.Text:=inttostr(strtoint(Me
mAngka) mod
strtoint(memo1.Text));
if MemOperator='div' then
memo1.Text:=inttostr(strtoint(Me
mAngka)div
strtoint(memo1.Text));
if MemOperator='^' then
memo1.Text:=floattostr(exp(strto
float(memo1.Text)*ln(strtofloat(M
emAngka))));
MemAngka:=memo1.Text;
MemOperator:='+';
MemLogic:='0';
end;
end;
procedure TFormKalkulator.ButtonPointClick(Sender: TObject);
begin
if memo1.text<>'' then
memo1.Text:=memo1.Text + '.';
{menambahkan tanda desimal(titik) pada teks dari memo}
end;
procedure TFormKalkulator.ButtonResultClick(Sender: TObject);
begin
if MemOperator='+' then
memo1.Text:=floattostr(strtofloat
(MemAngka)
+strtofloat(memo1.Text));
if MemOperator='-' then
memo1.Text:=floattostr(strtofloat
(MemAngka)-
strtofloat(memo1.Text));
if MemOperator='x' then
memo1.Text:=floattostr(strtofloat
(MemAngka)*strtofloat(memo1.Te
xt));
if MemOperator='/' then
memo1.Text:=floattostr(strtofloat
(MemAngka)/strtofloat(memo1.Te
xt));
30
if MemOperator='mod' then
memo1.Text:=inttostr(strtoint(Me
mAngka) mod
strtoint(memo1.Text));
if MemOperator='div' then
memo1.Text:=inttostr(strtoint(Me
mAngka)div
strtoint(memo1.Text));
if MemOperator='^' then
memo1.Text:=floattostr(exp(strto
float(memo1.Text)*ln(strtofloat(M
emAngka))));
MemAngka:=memo1.Text;
MemLogic:='0';
end;
procedure TFormKalkulator.ButtonSinClick(Sender: TObject);
var sudut:real;
begin
if memo1.Text<>'' then
begin
sudut:=strtofloat(memo1.Text);
if RbDeg.Checked = true then
sudut:=sudut*pi/180 else
if RbRad.Checked = true then
sudut:=sudut else
if RbGrads.Checked = true then
sudut:=sudut*pi/200;
memo1.Text :=
floattostr(sin(sudut));
MemLogic :='0';
end;
end;
procedure TFormKalkulator.ButtonTanClick(Sender: TObject);
var sudut:real;
begin
if memo1.Text<>'' then
begin
sudut:=strtofloat(memo1.Text);
if RbDeg.Checked = true then
sudut:=sudut*pi/180 else
if RbRad.Checked = true then
sudut:=sudut else
if RbGrads.Checked = true then
sudut:=sudut*pi/200;
memo1.Text :=
floattostr(tan(sudut));
MemLogic :='0';
end;
end;
procedure TFormKalkulator.FormCreate(Sender: TObject);
begin
memo1.Clear;{mengosongkan caption / lines dari memo1}
{menonaktifkan ketiga radiobutton}
31
RbDEG.Enabled:=false; RbRAD.Enabled:=false; RbGRADS.Enabled:=false;
end;
7. DERET
A. Deret Aritmatika
Masukan komponen di bawah ini :
Komponen Caption Visible
Label1 Menghitung Jumlah Suatu Deret
Aritmetika
True
Label2 Sn= 1/2 n(a+Un) dengan Un=a+
(n-1)b
True
Label3 Masukan Bilangan Pertama True
Label4 Nilai Beda Bilangan True
Label5 Banyaknya n Suku yang Dihitung True
Edit1 Kosongkan True
Edit2 Kosongkan True
Edit3 Kosongkan True
Bitbtn1 Selesai True
Button1 Deret Aritmatika True
Button2 Ulang True
Listbox1 false
Image1 True
32
Berikut ini merupakan listing programnya:
var
FormDrtAritmatika:
TFormDrtAritmatika;
i,n:integer;
a,b,m,Un,Sn:real;
implementation
uses U_Menu;
{$R *.dfm}
procedure TFormDrtAritmatika.BitBtn1Click(Sender: TObject);
begin
close;
end;
procedure TFormDrtAritmatika.Button1Click(Sender: TObject);
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
n:=strtoint(edit3.Text);
Un:=a+(n-1)*b;
Sn:=1/2*n*(a+Un);
m:= -1;
Listbox1.Items.Add(' Tampilan
Hasil Jumlah Deret Aritmetika ');
for i:=1 to n do
begin
m:=m+b;
listbox1.Items.add(' Nilai Suku Ke
'+inttostr(i)+' atauU '+inttostr(i)
+' = '+floattostr(m));
end;
Listbox1.Items.Add(' Nilai Suku
Pertama atau a= '+floattostr(a));
Listbox1.Items.Add(' Nilai Beda
Bilangan atau b= '+floattostr(b));
listbox1.Items.add(' Jumlah Deret
Aritmetika '+inttostr(n)+' Suku
Pertama= '
+floattostr(Sn));
listbox1.Visible:=true;
end;
procedure TFormDrtAritmatika.Button2Click(Sender: TObject);
begin
edit1.Clear; edit2.Clear; edit3.Clear; listbox1.Clear;
listbox1.Visible:=false;
end;
33
B. Deret Geometri
Kmponen pada Form Deret Geometri hampir sama dengan Form Deret
Aritmatika, namun yang berbeda itu pada label dan listing programnya.
Adapun listing programnya adalah sebagai berikut:
var
FormDrtGeometri: TFormDrtGeometri;
i,a,r,n:integer; P,Un,Sn:real;
implementation
uses U_Menu;
{$R *.dfm}
procedure TFormDrtGeometri.BitBtn1Click(Sender: TObject);
begin
a:=strtoint(edit1.text);
r:=strtoint(edit2.Text);
n:=strtoint(edit3.Text);
listbox1.Items.Add('Hasil
Perhitungan Deret Geometri');
listbox1.Items.Add('--------------------
---------------------------------');
P:=-1;
for i:=1 to n do
begin
P:=P+1;
Un:=a*(Exp(P*ln(r)));
listbox1.Items.Add('Nilai Suku Ke
'+inttostr(i)+' = '+floattostr(Un));
34
end;
listbox1.Items.Add('Nilai Suku
Pertama atau a = '+inttostr(a));
listbox1.Items.Add('Perbandingan
Bilangan atau r = '+inttostr(r));
Sn:=(a*exp(n*ln(r))-1)/(r-1);
listbox1.items.add('Jumlah Deret
Geometri '+inttostr(n)
+' Suku Partama =
'+floattostr(Sn));
listbox1.Visible:=true;
end;
procedure TFormDrtGeometri.BitBtn2Click(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
listbox1.Clear;
listbox1.Visible:=false;
end;
procedure TFormDrtGeometri.BitBtn3Click(Sender: TObject);
begin
close;
end;
8. VOLUME DAN LUAS PERMUKAAN
a.Volume dan Luas Permukaan Kubus
35
var
FormVLpKubus: TFormVLpKubus;
s:string; a,p,i:integer; Sisi :array[1..30]of string;
V,L:real;
implementation
uses U_Menu; {$R *.dfm}
procedure TFormVLpKubus.Button1Click(Sender: TObject);
begin
edit1.Clear;
listbox1.Items.Clear;
s:=inputbox('Loop','Jumlah
Perulangan','');
p:=strtoint(s);
for i := 1 to p do
begin
Sisi[i]:=inputbox('ID','Sisi','');
edit1.Text:=Sisi[i];
end;
end;
procedure TFormVLpKubus.Button2Click(Sender: TObject);
begin
listbox1.Clear; image2.Visible:=false; edit1.Clear;
listbox1.Visible:=false;
end;
procedure TFormVLpKubus.Button3Click(Sender: TObject);
begin close; end;
procedure TFormVLpKubus.Button4Click(Sender: TObject);
begin
a:=strtoint(edit1.Text);
V:=a*a*a;
listbox1.Items.Add('Jadi volume
kubus adalah ='+inttostr(a)+' x
'+inttostr(a)+' x '+inttostr(a)+' =
'+floattostr(V));
L:=6*a*a;
Listbox1.Items.Add('Jadi luas
permukaan kubus adalah = 6
('+inttostr(a)+' X '+inttostr(a)
+' ) '+' = '+floattostr(L));
image2.Visible:=true;
listbox1.Visible:=true;
end;
b.Volume dan Luas Permukaan Balok
36
procedure
TFormVLpBalok.BitBtn1Click(S
ender: TObject);
var panjang,lebar,tinggi:integer;
V,L:real;
begin
panjang:=strtoint(edit1.Text);
lebar:=strtoint(edit2.Text);
tinggi:=strtoint(edit3.Text);
V:=panjang*lebar*tinggi;
listbox1.Items.Add('Jadi
Volumenya Adalah '+' =
'+inttostr(panjang)+' X
'+inttostr(lebar)+' X
'+inttostr(tinggi)+' =
'+floattostr(V));
L:=
2*(panjang*lebar+panjang*ting
gi+lebar*tinggi);
listbox1.Items.Add('Jadi Luas
Permukaanya Adalah =' +
'2('+inttostr(panjang)
+'x'+inttostr(lebar)
+'+'+inttostr(panjang)
+'x'+inttostr(tinggi)
+'+'+inttostr(lebar)
+'x'+inttostr(tinggi)
+')='+floattostr(L));image1.visib
le:=true;
end;
procedure TFormVLpBalok.BitBtn2Click(Sender: TObject);
begin
edit1.Clear; edit2.Clear; edit3.Clear; listbox1.Clear;
image1.Visible:=false;
end;
procedure TFormVLpBalok.BitBtn3Click(Sender: TObject);
begin close; end;
procedure TFormVLpBalok.Timer1Timer(Sender: TObject);
begin
if label1.Visible=true then
label1.Visible:=false
else
37
label1.Visible:=true; end;
c. Volume dan Luas Permukaan Bola
procedure
TFormVLpBola.Button1Click(S
ender: TObject);
var
r:integer; Volume,Luas:real;
begin
r:=strtoint(edit1.Text);
Volume:=3/4*3.14*r*r*r;
edit2.Text:=floattostr(Volume);
Luas:=4*3.14*r*r;
edit3.Text:=floattostr(Luas);
image1.Visible:=true;
image2.Visible:=false;
end;
procedure
TFormVLpBola.Button2Click(S
ender: TObject);
begin
edit1.Clear; edit2.Clear;
edit3.Clear;
image1.Visible:=false;
image2.Visible:=true;
end;
procedure
TFormVLpBola.Button3Click(S
ender: TObject);
begin
close;
end;
9. PERSAMAAN KUADRAT
var
FormPersKuadrat:
TFormPersKuadrat;
A,B,C,D,E,F,G:real;
implementation
uses U_Menu;
{$R *.dfm}
38
procedure
TFormPersKuadrat
.BitBtn1Click(Send
er: TObject);
begin
A:=strtofloat(edit1.T
ext);
B:=strtofloat(edit2.T
ext);
C:=strtofloat(edit3.T
ext);
D:=B*B-4*A*C;
edit4.Text:=floattost
r(D);
if D=0 then
begin
E:=-B/(2*A);
F:=-B/(2*A);
edit5.Text:=floattost
r(E);
edit6.Text:=floattost
r(F);
Label10.visible:=tru
e;
G:=(E*E)+
(F*F);edit7.Text:=flo
attostr(G);end
else if D>0
thenbegin
E:=(-B +
Sqrt(D))/(2*A);
F:=(-B -
Sqrt(D))/(2*A);
edit5.Text:=floattost
r(E);
edit6.Text:=floattost
r(F);
Label14.visible:=tru
e;
G:=(E*E)+(F*F);
edit7.Text:=floattost
r(G);
end
else if D<0 then
begin
E:=-B/(2*A);
F:=Sqrt(-D)/(2*A);
edit5.Text:=floattost
r(E);
edit6.Text:=floattost
r(F);
Label15.visible:=tru
e;
G:=(E*E)+(F*F);
edit7.Text:=floattost
r(G);
end;
end;
procedure TFormPersKuadrat.BitBtn3Click(Sender: TObject);
begin close; end;
procedure TFormPersKuadrat.Button1Click(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
edit7.Clear;
label10.visible:=fals
e;
label14.visible:=fals
e;
label15.visible:=fals
e;
end;
procedure TFormPersKuadrat.Timer1Timer(Sender: TObject);
begin
if label10.left<-
label10.Width then
label10.Left:=Width
else
label10.Left:=label1.
Left-1;
39
if label15.left<-
label15.Width then
label15.Left:=Width
else
label15.Left:=label1
5.Left-1;
if label14.left<-
label14.Width then
label14.Left:=Width
else
label14.Left:=label1
4.Left-1;
end;
10.FAKTORIAL
var
FormFaktorial: TFormFaktorial;
a,i,j,jumlah,fakt1,fakt2:integer;
bilangan:array[1..20]of integer;
implementation
uses U_Menu; {$R
*.dfm}
procedure
TFormFaktorial.BitBtn1Click(S
ender: TObject);
begin
bilangan[a]:=strtoint(edit2.Text);
for a:= 1 to 5 do
jumlah:=jumlah+bilangan[a];
listbox1.Items.Add('Jumlah
Bilangan = '+inttostr(jumlah));
fakt2:=1;
for j := 2 to jumlah do
fakt2:=fakt2*j;
listbox1.Items.Add('Faktorial dari
'+inttostr(jumlah)+' adalah
='+inttostr(fakt2));
end;
procedure TFormFaktorial.BitBtn2Click(Sender: TObject);
begin
a:=1;
edit1.Text:=inttostr(
a);
edit2.Clear;
listbox1.Clear;
end;
procedure TFormFaktorial.BitBtn3Click(Sender: TObject);
begin close; end;
procedure TFormFaktorial.Button1Click(Sender: TObject);
begin if a<=5 then
40
bilangan[a]:=strtoint
(edit2.Text);
edit2.SetFocus;
fakt1:=1;
for i:=2 to
bilangan[a] do
fakt1:=fakt1*i;
listbox1.Items.Add('
Data Ke '+inttostr(a)
+' :
'+inttostr(bilangan[a
])+', Faktorialnya
adalah
='+inttostr(fakt1));
if a<5 then
begin
a:=a+1;
edit1.Text:=inttostr(
a);
end
else
if a=5 then
messagedlg('STOP
Data Bilangan Sudah
5
buah',mtinformation,
[mbYes],0);
end;
procedure
TFormFaktorial.Fo
rmCreate(Sender:
TObject);
begin
a:=1;
edit1.Text:=inttostr(
a);
end;
11.KONVERSI
SUHU
procedure
TFormKonversiSu
hu.Button1Click(S
ender: TObject);
begin
if Edit1.Text <> ''
then
begin
Edit2.Text :=
floattostr(strtofloat(E
dit1.Text)*9/5+32) +
'°';
Edit3.Text :=
floattostr(strtofloat(E
dit1.Text)*4/5) + '°';
Edit4.Text :=
floattostr(strtofloat(E
dit1.Text)+273)+
'°' ;
Edit1.Text :=
Edit1.Text + '°';
end;
end;
procedure TFormKonversiSuhu.Button2Click(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit1.SetFocus;
end;
41
procedure TFormKonversiSuhu.Button3Click(Sender: TObject);
begin close; end;
procedure TFormKonversiSuhu.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if key = #13 then
Button1.Click;
end;
procedure TFormKonversiSuhu.FormCreate(Sender: TObject);
VAR
busur:HRGN;
oke:HBRUSH;
setengah:HDC;
begin
busur:=createelliptic
rgn(5,5,500,500);
setwindowrgn(handl
e,busur,true);
deleteobject(busur);
end;
12.SELESAI
42
var
FormExit: TFormExit;
a,s:integer;
implementation
{$R *.dfm}
procedure
TFormExit.BitBtn1Click(Sende
r: TObject);
begin
application.Terminate;
end;
procedure TFormExit.Timer1Timer(Sender: TObject);
begin
a:=a+1;
if a=1 then
label1.visible:=true;
if a=2 then
label2.Visible:=true;
if a=3 then
label3.Visible:=true;
if a=4 then
label4.Visible:=true;
if a=5 then
begin
label1.visible:=false;
label2.visible:=false;
label3.visible:=false;
label4.visible:=false;
a:=0;
end;
end;
SCRIBD.COM
43
TERIMA KASIH
PENERAPAN PEMROGRAMAN DELPHI (ARRAY)
DALAM INPUT DATA MAHASISWA DAN
PERMASALAHAN MATEMATIKA
Diajukan Untuk Memenuhi Tugas Program Komputer
Dosen : Deddy Sofyan, M.Pd.
Disusun oleh:
Supian
44
[ 09512038 ]
Prog. Studi : Pendidikan Matematika S-I
SEKOLAH TINGGI KEGURUAN DAN ILMU
PENDIDIKAN (STKIP)
GARUT
45