Sei sulla pagina 1di 190

LATIHAN 1

Objek
Form1
Label1
Label2
Label3
Edit1
Edit2
Button1
Button2
Button3

Properti
Nilai Properti
Caption
Latihan 1
Caption
DATA MAHASISWA
Font
Name: Tahoma, Size: 15,
Style: fsBold (True)
Caption
NAMA
Font
Name: Tahoma, Size: 12
Caption
ALAMAT
Font
Name: Tahoma, Size: 12
Text
(Kosongkan)
Text
(Kosongkan)
Caption
Proses
Caption
Hapus
Caption
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
1

Button1: TButton;
Button2: TButton;
Button3: TButton;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
label4.Caption:=edit1.Text;
label5.Caption:=edit2.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label4.Caption:='';
edit1.Text:='';
label5.Caption:='';
edit2.Text:='';
edit1.setfocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.

LATIHAN 2
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Edit1
Edit2
Button1
Button2
Button3
Button4
Button5
Button6
Button7
Button8

Properti
Nilai Properti
Caption
Latihan 2
Caption
DATA MAHASISWA
Font
Name: Tahoma, Size: 15,
Style: fsBold (True)
Caption
NAMA
Font
Name: Tahoma, Size: 12
Caption
ALAMAT
Font
Name: Tahoma, Size: 12
Caption
(Kosongkan)
Caption
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Caption
Proses
Caption
Verdana
Caption
Lucida
Caption
Ukuran 20
Caption
Merah
Caption
Biru
Caption
Normal
Caption
Keluar

unit Unit1;
interface
uses
3

Windows, Messages, SysUtils, Variants, Classes,


Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Label4.Caption:=edit1.Text;
4

Label5.Caption:=edit2.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
label4.Font.Name:='verdana';
label5.Font.Name:='verdana';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
label4.Font.size:=20;
label5.Font.Size:=20;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
label4.Font.Name:='Ms sans serif';
label5.Font.Name:='Ms Sans Serif';
label4.Font.size:=8;
label5.Font.Size:=8;
label4.Font.Color:=cldefault;
label5.Font.color:=cldefault;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
label4.Font.Color:=clblue;
label5.Font.color:=clblue;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
label4.Font.Color:=clred;
label5.Font.color:=clred;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
label4.Font.Name:='Lucida handwriting';
label5.Font.Name:='Lucida handwriting';
5

end;
end.

LATIHAN 3
Objek
Form1
Label1
Button1
Button2
Button3

Properti
Nilai Properti
Caption
Latihan 3
Caption
Tombol Belum Ditekan
Font
Name: Tahoma, Size: 14,
Style: fsBold (True)
Caption
Belum ditekan
Caption
Belum direset
Enabled
False
Caption
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
7

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption:='Tombol Sudah di Tekan';
button2.Caption:='Tombol Belum di Reset';
button1.Caption:='Tombol Sudah di Tekan';
button1.Enabled:=false;
button2.enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
button1.enabled:=true;
button2.enabled:=false;
button1.Caption:='Tombol Belum di Tekan';
button2.Caption:='Tombol Sudah di Reset';
Label1.Caption:='Tombol Sudah di Reset';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
end.

LATIHAN 4
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Label6
Label7
Label8
Label9
Edit1
Edit2
ComboBo
x1

Propert
Nilai Properti
i
Caption Latihan 4
Caption DATA MAHASISWA
Font
Name: Tahoma, Size: 14,
Style: fsBold (True)
Caption N I M
Caption NAMA
Caption JURUSAN
Caption PRODI
Caption (Kosongkan)
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Caption (Kosongkan)
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Caption (Kosongkan)
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Caption (Kosongkan)
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Text
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Items

ListBox1

Items

Button1
Button2

Caption
Caption

Matematika, Fisika, Kimia,


Biologi
Matematika, Pend. Matematika,
Fisika, pend. Fisika, Kimia,
Pend. Kimia, Biologi, Pend.
Biologi
Hapus
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
ComboBox1: TComboBox;
ListBox1: TListBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Button1: TButton;
Button2: TButton;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
10

procedure Button1Click(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1Change(Sender: TObject);
begin
label6.Caption:=edit1.Text;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
label7.Caption:=edit2.Text;
end;
procedure
TForm1.ComboBox1Change(Sender:
TObject);
begin
label8.Caption:=combobox1.Text;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
label9.Caption:=listbox1.Items[listbox1.itemindex]
;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:='';
Edit2.text:='';
Label6.caption:='';
Label7.caption:='';
Label8.caption:='';
11

Label9.caption:='';
end;
end.

12

LATIHAN 5
Objek
Form1
GroupBox1
GroupBox2
CheckBox1
CheckBox2
CheckBox3
CheckBox4
CheckBox5
CheckBox6
CheckBox7
CheckBox8
CheckBox9
CheckBox1
0
CheckBox1
1
CheckBox1
2
Memo1
Button1
Button2
Button3

Proper
ti
Caption
Caption
Sisipi
Caption
Sisipi
Caption
Caption
Caption
Caption
Caption
Caption
Caption
Caption
Caption
Caption

Nilai Properti
Latihan 5
JURUSAN
CheckBox1-4
PROGRAM STUDI
CheckBox5-12
Kimia
Biologi
Matematika
Fisika
Kimia
Biologi
Matematika
Fisika
Pend. Kimia
Pend. Biologi

Caption Pend. Matematika


Caption Pend. Fisika
Lines
Caption
Caption
Caption

(Kosongkan)
Proses
Hapus
Keluar

13

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
ck1: TCheckBox;
ck2: TCheckBox;
ck3: TCheckBox;
ck4: TCheckBox;
ck5: TCheckBox;
ck6: TCheckBox;
ck7: TCheckBox;
ck8: TCheckBox;
ck9: TCheckBox;
ck10: TCheckBox;
ck11: TCheckBox;
ck12: TCheckBox;
memo1: TMemo;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
14

procedure Button3Click(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if ck1.Checked or ck2.Checked or ck3.Checked or
ck4.Checked then
memo1.Lines.add(groupbox1.Caption);
if
ck1.Checked
then
memo1.Lines.add(ck1.Caption);
if
ck2.Checked
then
memo1.Lines.add(ck2.Caption);
if
ck3.Checked
then
memo1.Lines.add(ck3.Caption);
if
ck4.Checked
then
memo1.Lines.add(ck4.Caption);
memo1.lines.add('');
if ck5.Checked or ck6.Checked or ck7.Checked or
ck8.Checked or ck9.Checked or ck10.Checked or
ck11.Checked or ck12.Checked then
memo1.Lines.add(groupbox2.Caption);
if
ck5.Checked
then
memo1.Lines.add(ck5.Caption);
if
ck6.Checked
then
memo1.Lines.add(ck6.Caption);
if
ck7.Checked
then
memo1.Lines.add(ck7.Caption);
15

if
ck8.Checked
then
memo1.Lines.add(ck8.Caption);
if
ck9.Checked
then
memo1.Lines.add(ck9.Caption);
if
ck10.Checked
then
memo1.Lines.add(ck10.Caption);
if
ck11.Checked
then
memo1.Lines.add(ck11.Caption);
if
ck12.Checked
then
memo1.Lines.add(ck12.Caption);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ck1.Checked:=false;
ck2.Checked:=false;
ck3.Checked:=false;
ck4.Checked:=false;
ck5.Checked:=false;
ck6.Checked:=false;
ck7.Checked:=false;
ck8.Checked:=false;
ck9.Checked:=false;
ck10.Checked:=false;
ck11.Checked:=false;
ck12.Checked:=false;
memo1.lines.Clear;
end;
end.

16

LATIHAN 6
Objek
Form1
Label1
Label2
Image1
Button1
Button2
Button3
Button4

Properti
Caption
Caption
Caption
Proportion
al
Caption
Caption
Caption
Caption

Nilai Properti
Latihan 6
TAMPILAN GAMBAR
(Kosongkan)
True
Gb 1
Gb 2
Gb 3
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, jpeg,
ExtCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
Image1: TImage;
Label1: TLabel;
Button4: TButton;
Label2: TLabel;
Button1: TButton;
Button3: TButton;
17

procedure Button2Click(Sender: TObject);


procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
image1.picture.LoadFromFile('c:/b.jpg');
button1.Enabled:=true;
button2.Enabled:=false;
button3.Enabled:=true;
Label2.Caption:='Gambar 2';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
image1.picture.LoadFromFile('a.jpg');
button1.Enabled:=false;
button2.Enabled:=true;
button3.Enabled:=true;
Label2.Caption:='Pak Dekan dan Pak Sigit';
Label1.Caption:=TAMPILAN GAMBAR';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
image1.picture.LoadFromFile('c:/c.jpg');
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=false;
Label2.Caption:='Gambar 3';
end;
18

procedure TForm1.Button4Click(Sender: TObject);


begin
Application.Terminate;
end;
end.

19

LATIHAN 7
Objek
Properti
Nilai Properti
Form1
Caption
Latihan 7
RadioGroup Caption
HITUNG
1
Items
Perkalian, Penjumlahan,
Pengurangan, Pembagian
ItemInde 0
x
Columns 2
Label1
Caption
X
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Label2
Caption
=
Font
Name: Tahoma, Size: 12,
Style: fsBold (True)
Edit1
Text
(Kosongkan)
Edit2
Text
(Kosongkan)
Edit3
Text
(Kosongkan)
Button1
Caption
Ulangi
Button2
Caption
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
20

rg1: TRadioGroup;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Button3: TButton;
Button2: TButton;
procedure rg1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,b,c:real;
implementation
{$R *.dfm}
procedure TForm1.rg1Click(Sender: TObject);
begin
if rg1.ItemIndex=0 then
begin
Label1.Caption:='X';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
edit1.setfocus;
end else if rg1.ItemIndex=1 then
begin
Label1.Caption:='+';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
edit1.setfocus;
end else if rg1.ItemIndex=2 then
21

begin
Label1.Caption:='-';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
edit1.setfocus;
end else if rg1.ItemIndex=3 then
begin
Label1.Caption:='/';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
edit1.setfocus;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if rg1.ItemIndex=0 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=b*a;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=1 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=b+a;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=2 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=a-b;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=3 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
22

if b=0 then
begin messagedlg ('Goblok!!? 0 Tidak Bisa
Untuk Membagi',mtwarning,[mbOk],0);
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end else
c:=a/b;
edit3.Text:=floattostr(c);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit1.setfocus;
end;
end.

23

LATIHAN 8
Objek
Form1
Button1
Button2
Button3
Panel1
StatusBar1

Properti
Caption
Caption
Caption
Caption
Caption
Font

Nilai Properti
Latihan 8
Text
Gambar
Keluar
Agung Tri Prasetya
Name: Tahoma, Size: 12,
Style: fsUnderline (True)
Autohint :True;
Parentshowhint:true;
Simplepanel:true;

unit Unit12;
interface
uses

24

Windows, Messages, SysUtils, Variants, Classes,


Graphics, Controls, Forms, Dialogs, ExtCtrls,jpeg,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Panel1: TPanel;
RichEdit1: TRichEdit;
Image1: TImage;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit1, Unit3;
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
richedit1.Visible:=false;
image1.Visible:=true;
image2.Visible:=false;
image1.Picture.loadfromfile('a.jpg');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
richedit1.Visible:=true;
image1.Visible:=false;
image2.Visible:=false;
richedit1.lines.loadfromfile('tulisan.rtf');
25

end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
Aboutbox.ShowModal;
end;
end.
unit Unit3;
interface
uses
Windows, SysUtils, Classes, Graphics,
Controls, StdCtrls, Buttons, ExtCtrls;
type
TAboutBox = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
ProductName: TLabel;
Version: TLabel;
Copyright: TLabel;
Comments: TLabel;
OKButton: TButton;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutBox: TAboutBox;
implementation
{$R *.dfm}

Forms,

26

end.

27

LATIHAN 9
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Label6
Edit1
Edit2
Edit3
Button1
Button2
Button3

Properti
Nilai Properti
Caption
Latihan 9
Caption
PROGRAM HITUNG TEKANAN
Font
Name: Tahoma, Size: 16,
Style: fsBold (True)
Caption
Volume (L)
Caption
Jumlah Mol
Caption
Suhu (K)
Caption
Tekanan
Caption
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Caption
Proses
Caption
Ulangi
Caption
Keluar

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
28

Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
label5: TLabel;
edit1: TEdit;
edit2: TEdit;
edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label6: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,p,t,v: real;
const
R=0.081;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
application.terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
N:=strtofloat(edit2.text);
t:=strtofloat(edit3.text);
V:=strtofloat(edit1.text);
p:=(n*R*T)/v;
label6.Caption:=floattostr(p);
end;
procedure TForm1.Button2Click(Sender: TObject);
29

begin
edit1.text:='';
edit2.text:='';
edit3.text:='';
label6.Caption:='';
edit1.setfocus;
end;
end.

30

LATIHAN 10
Objek

Propert
Nilai Properti
i
Form1
Caption Latihan 10
Label1 Caption Bilangan yang akan dihitung
akarnya
Label2 Caption (Kosongkan)
Edit1
Text
(Kosongkan)
Button1 Caption Hitung
Button2 Caption Keluar

unit Ulat11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
31

public
{ Public declarations }
end;
var
Form1: TForm1;
x,y:real;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
y:=strtofloat(edit1.Text);
x:=sqrt(y);
label2.Caption:='Akar dari ' + edit1.Text + '
adalah ' + floattostr(x);
edit1.SetFocus;
end;
end.

32

LATIHAN 11
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Edit1
Edit2
Button1
Button2
Button3

Properti
Caption
Caption
Caption
Caption
Caption
Caption
Text
Text
Caption
Caption
Caption

Nilai Properti
Latihan 11
Bilangan Pokok
Pangkat
(Kosongkan)
(Kosongkan)
(Kosongkan)
(Kosongkan)
(Kosongkan)
Hitung
Ulangi
Keluar

unit Ulat12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
33

Label5: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,b,c:real;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
b:=strtofloat(edit1.Text);
c:=strtofloat(edit2.Text);
a:=exp(c*ln(b));
label3.Caption:=edit1.Text;
label4.Caption:=edit2.Text;
label5.Caption:=' = '+floattostr(a);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
label3.Caption:='';
label4.Caption:='';
label5.Caption:='';
34

edit1.SetFocus;
end;
end.

35

LATIHAN 12
Objek Propert
Nilai Properti
i
Form1 Caption Latihan 12
Label1 Caption HITUNG ENERGI LINTASAN
ELEKTRON
Font
Name: Tahoma, Size: 14,
Style: fsBold (True)
Label2 Caption Berapa Lintasannya
Label3 Caption Berapa Massanya
Label4 Caption Berapa Lintasannya
Label5 Caption HASIL
Memo Lines
(Kosongkan)
1
ScrollBar ssVertical
s
Button Caption Hitung
1
Button Caption Ulangi
2
Button Caption Keluar
3

unit Ulat13;
36

interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,i:byte;
m,a:real;
e:double;
const
h=6.62e-34;
ev=1.6e+19;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=strtoint(edit1.Text);
37

m:=strtofloat(edit2.Text);
a:=strtofloat(edit3.Text);
for i:=1 to n do
begin
e:=(sqr(h)*sqr(i))/(8*m*sqr(a));
e:=e*ev;
memo1.Lines.Add('Lintasan = ' +
inttostr(i) + ' maka E = '+floattostr(e)+ '
eV');
memo1.Lines.Add('');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
memo1.Lines.Clear;
edit1.setfocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.

38

LATIHAN 13
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Label6
Label7
Label8
Label9
Label10
Label11
Label12
Label13
Label14
Label15
Label16
Label17
Label18
Label19
Edit1
Edit2
Edit3
Edit4
Button1
Button2
Button3

Properti
Nilai Properti
Caption
Latihan 13
Caption
SOAL
Font
Name: Tahoma, Size: 14,
Style: fsBold (True)
Caption
Larutan A liter yang
mengandung B mol NaCl
dicampur dengan
Caption
C liter larutan yang
mengandung D mol Perak
Nitrat
Caption
KSP Perak Nitrat = 18 x 10
Caption
-18
Caption
Apakah Akan Terjadi Endapan ?
Caption
Diketahui
Caption
A=
Caption
B=
Caption
C=
Caption
D=
Caption
Jawab:
Caption
(Kosongkan)
Caption
(Kosongkan)
Caption
(Kosongkan)
Caption
(Kosongkan)
Caption
(Kosongkan)
Caption
(Kosongkan)
Caption
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Caption
Hitung
Caption
Ulangi
Caption
Keluar

39

unit Ulat14;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
40

Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form1: TForm1;
a,b,c,d,e,f,g,h:real;
Const
ksp=1.8e-10;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=strtofloat(edit3.Text);
d:=strtofloat(edit4.Text);
e:=a+c;
f:=b/e;
g:=d/e;
h:=f*g;
label13.Caption:=floattostr(a) + liter larutan
mengandung + floattostr(b) + mol Cl-;
label14.Caption:=floattostr(c) + liter larutan
mengandung + floattostr(d) + mol Ag+;
label15.Caption:=Volume campuran = +
floattostr(e) + liter;
41

label16.Caption:=[Cl-] = + floattostr(b) + / +
floattostr(e) + mol/liter = + floattostr(f) +
mol/liter;
label17.Caption:=[Ag+] = + floattostr(d) + / +
floattostr(e) + mol/liter = + floattostr(g) +
mol/liter;
label18.Caption:=[Ag+][Cl-] = + floattostr(f) +
x + floattostr(g) + = + floattostr(h);
if h < ksp then
begin
label19.Caption:=Karena [Ag+][Cl-] < Ksp
maka AgCl tidak mengendap;
end else
label19.Caption:=Karena [Ag+][Cl-] > Ksp
maka AgCl mengendap;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:=;
edit2.Text:=;
edit3.Text:=;
edit4.Text:=;
label13.Caption:=;
label14.Caption:=;
label15.Caption:=;
label16.Caption:=;
label17.Caption:=;
label18.Caption:=;
label19.Caption:=;
edit1.setfocus;
end;
end.

42

LATIHAN 14
Objek
Form1

Properti
Caption
BorderStyl
e
Panel1
Caption
BevelInne
r
BevelOute
r
RadioGroup Caption
1
Items
Button1
Button2

Caption
Caption

Nilai Properti
Latihan 14
bsNone
(Kosongkan)
byRaised
byLowered
(Kosongkan)
Setuju
Tidak Setuju
Keluar
Lanjut >>

Objek
Form2
Label1

Properti
Nilai Properti
Caption
Latihan 14
Caption
TEORI
Font
Name: Tahoma, Size: 16,
Style: fsBold (True)
RichEdit Lines
(Kosongkan)
1
ScrollBars ssNone
ReadOnly True
Button1 Caption
Teori
Button2 Caption
Latihan 1
Button3 Caption
Latihan 2
Button4 Caption
Latihan 3
Button5 Caption
Latihan 4
43

Button6
Button7
Button8

Caption
Caption
Caption

Soal
Kembali
Keluar

unit Ugab3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, ExtCtrls, shellapi,
StdCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
RadioGroup1: TRadioGroup;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
44

end;
Var
Form1: TForm1;
implementation
uses Unit2, Ugab2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Enabled:=false;
button2.Enabled:=false;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
if radiogroup1.ItemIndex=0 then
begin
button1.Enabled:=true;
button2.Enabled:=true;
end else if radiogroup1.ItemIndex=1 then
begin
button1.Enabled:=true;
button2.Enabled:=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Visible:=false;
form2.visible:=true;
end;
end.
unit Ugab2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, shellapi, StdCtrls,
ComCtrls;
45

type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
RichEdit1: TRichEdit;
Button8: 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 FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form2: TForm2;
implementation
uses Ugab1, Ugab3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.Visible:=false;
46

form1.Visible:=true;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
form2.Visible:=false;
form3.Visible:=true;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan1.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan2.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan3.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan4.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
richedit1.Visible:=true;
richedit1.Lines.LoadFromFile('tulisan.rtf');
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
richedit1.Visible:=false;
end;
end.

47

LATIHAN 15
Objek
Form1
Label1

Properti
Caption
Caption
Font

RichEdit1

Lines
ScrollBars
ReadOnly
Image1
Proportion
al
Image2
Picture
Panel1
Caption
MediaPlaye Visible
r1
StatusBar1 AutoHint
Button1
Caption
Button2
Caption
Button3
Caption
Button4
Caption
Button5
Caption
* = Ukuran sama besar

Nilai Properti
Latihan 15
MEDIA TEKS, GAMBAR DAN
VIDEO
Name: Tahoma, Size: 16,
Style: fsBold (True)
(Kosongkan)*
ssNone
True
True *
Isi dengan File logo UNNES
(Kosongkan)*
False
True
Tulisan
Gambar
Video
Stop
Keluar

unit Ulatfilm;
48

interface
uses
Windows, jpeg, shellapi, mplayer,Messages, SysUtils,
Variants, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
RichEdit1: TRichEdit;
Label1: TLabel;
StatusBar1: TStatusBar;
Image1: TImage;
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
Button4: TButton;
Button5: TButton;
Image2: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
button4.Visible:=false;
panel1.Visible:=false;
image1.Visible:=false;
49

image2.Visible:=false;
richedit1.Visible:=true;
richedit1.Lines.LoadFromFile('tulisan.rtf');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
button4.Visible:=false;
panel1.Visible:=false;
image1.Visible:=true;
image2.Visible:=false;
richedit1.Visible:=false;
image1.picture.LoadFromFile('A.jpg');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
button1.Enabled:=false;
button2.Enabled:=false;
button3.Enabled:=false;
button4.Visible:=true;
panel1.Visible:=false;
image1.Visible:=false;
image2.Visible:=false;
richedit1.Visible:=false;
mediaplayer1.FileName:='video.avi';
mediaplayer1.open;
panel1.show;
mediaplayer1.display:=panel1;
mediaplayer1.displayrect:=rect(2,2,width,height);
mediaplayer1.play;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
mediaplayer1.Stop;
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=true;
button4.Visible:=false;
panel1.Visible:=false;
image2.Visible:=true;
50

end;
procedure TForm1.FormCreate(Sender: TObject);
begin
image2.Visible:=true;
image1.Visible:=false;
richedit1.Visible:=false;
panel1.Visible:=false;
button4.Visible:=false;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if messagedlg ('Anda yakin akan keluar ?',
mtconfirmation, mbokcancel,0) = mrok then
application.Terminate;
end;
end.

51

Objek
Form1
Label1
Label2
Label3
Label4
Label5
Edit1
Edit2
Button1
Button2
Button3
Button4
Button5
Button6
Button7
Button8

LATIHAN 16
Properti
Nilai Properti
Caption
Latihan 2
Caption
DATA MAHASISWA
Font
Name: Tahoma, Size: 15,
Style: fsBold (True)
Caption
NAMA
Font
Name: Tahoma, Size: 12
Caption
ALAMAT
Font
Name: Tahoma, Size: 12
Caption
(Kosongkan)
Caption
(Kosongkan)
Text
(Kosongkan)
Text
(Kosongkan)
Caption
Proses
Caption
Verdana
Caption
Lucida
Caption
Ukuran 20
Caption
Merah
Caption
Biru
Caption
Normal
Caption
Keluar

52

unit ulatsoal;
interface
uses
Windows, shellapi, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
re1: TRichEdit;
Kalkulator: TButton;
SPU: TButton;
Label1: TLabel;
Waktu: TLabel;
Label3: TLabel;
A: TButton;
B: TButton;
C: TButton;
D: TButton;
Edit1: TEdit;
Ket1: TLabel;
Ket2: TLabel;
Mulai: TButton;
next: TButton;
keluar: TButton;
Timer: TTimer;
StatusBar1: TStatusBar;
procedure KalkulatorClick(Sender: TObject);
procedure SPUClick(Sender: TObject);
procedure keluarClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MulaiClick(Sender: TObject);
procedure nextClick(Sender: TObject);
procedure AClick(Sender: TObject);
procedure BClick(Sender: TObject);
procedure CClick(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure DClick(Sender: TObject);
private
{ Private declarations }
53

public
{ Public declarations }
end;
Var
Form1: TForm1;
xb,fni,js,jb,x:integer;
xs,fns,jss,jbs,filename:string;
implementation
{$R *.dfm}
procedure TForm1.KalkulatorClick(Sender: TObject);
begin
shellexecute(handle,'open','soal/calc.exe',nil,nil,sw_
show);
end;
procedure TForm1.SPUClick(Sender: TObject);
begin
shellexecute(handle,'open','soal/spu.exe',nil,nil,sw_
show);
end;
procedure TForm1.keluarClick(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
label1.Visible:=false;
label3.Visible:=false;
waktu.Visible:=false;
a.Visible:=false;
b.Visible:=false;
c.Visible:=false;
d.Visible:=false;
edit1.Visible:=false;
ket1.Visible:=false;
ket2.Visible:=false;
next.Visible:=false;
54

re1.Visible:=false;
mulai.visible:=true;
kembali.visible:=true;
keluar.visible:=true;

end;
procedure TForm1.MulaiClick(Sender: TObject);
begin
label1.Visible:=true;
label3.Visible:=true;
waktu.Visible:=true;
a.Visible:=true;
b.Visible:=true;
c.Visible:=true;
d.Visible:=true;
edit1.Visible:=true;
ket1.Visible:=true;
ket2.Visible:=true;
next.Visible:=true;
re1.Visible:=true;
mulai.Visible:=false;
filename:='11';
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
js:=1;
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal : '+jss;
jb:=0;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar : '+jbs;
timer.Enabled:=true;
x:=0;
end;
procedure TForm1.nextClick(Sender: TObject);
begin
edit1.text:='';
a.Enabled:=true;
b.Enabled:=true;
c.Enabled:=true;
d.Enabled:=true;
re1.visible:=true;
55

f');

js:=js+1;
fni:=strtoint(filename);
fni:=fni+1;
if fni>15 THEN
fni:=11;
fns:=inttostr(fni);
filename:=fns;
re1.Lines.LoadFromFile('soal/'+filename+'.rt
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal: ' +jss;
if ket1.Caption='Jumlah Soal: 5' then
next.Enabled:=false;

end;
procedure TForm1.AClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
56

begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
next.Visible:=false;
end;
end;
procedure TForm1.BClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
57

begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
next.Visible:=false;
end;
end;
procedure TForm1.CClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
58

begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
next.Visible:=false;
end;
end;
procedure TForm1.TimerTimer(Sender: TObject);
begin
x:=x+2;
xs:=inttostr(600-x);
waktu.Caption:=xs+' detik';
xb:=strtoint(xs);
if xb=0 then
begin
mulai.Enabled:=true;
next.Enabled:=false;
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
x:=-1;
re1.clear;
timer.Enabled:=false;
waktu.caption:='600';
jb:=0;
js:=0;
end;
end;
procedure TForm1.DClick(Sender: TObject);
begin
59

a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='14' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
next.Visible:=false;
end;
end;
end.

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

60

LATIHAN 17

unit Upers_gas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
61

Label11: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Const
R = 0.0821;
var
Form1: TForm1;
Pid,Pre,Ptis,T,V,Pc,Vc,Tc,b,a,b2,a2 : extended;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
62

edit7.text:='';
edit8.Text:='';
edit9.Text:='';
edit10.Text:='';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
V:=strtofloat(edit1.Text);
t:=strtofloat(edit2.Text);
a:=strtofloat(edit3.Text);
b:=strtofloat(edit4.Text);
Pid := (R*T)/V;
b2 := (R*T)/(V-b);
a2 := a/sqr(V);
Pre := b2-a2;
Vc := 3*b;
Tc := a/(27*sqr(b));
Pc := (8*a)/(27*b*R);
Ptis := ((8*Pc*Vc*T)/(3*Tc*(V-(Vc/3))))((3*Pc*sqr(Vc))/sqr(V));
edit5.Text:=floattostr(vc);
edit6.Text:=floattostr(pc);
edit7.Text:=floattostr(tc);
edit8.Text:=floattostr(pid);
edit9.Text:=floattostr(pre);
edit10.Text:=floattostr(ptis);
end;
end.

63

LATIHAN 18

unit Ulat20;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
rg: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
64

Button2: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure rgClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
h1,h2,h3,oh1,oh2,oh3,ph1,ph2,ph3,ph4,ph5,ph6,p
oh1,poh2,poh3,ca,cb,ka,kb,d,d1,d2,d3 :double;
const
kw=10e-14;
implementation
{$R *.dfm}
procedure TForm1.rgClick(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
label1.Caption:='Konsentrasi Asam';
label2.Caption:='Konstanta Asam (Ka)';
label3.Caption:='';
label4.Caption:='';
label5.Caption:='';
edit1.Text:='';
edit2.Text:='';
end else if rg.ItemIndex=1then
begin
label1.Caption:='Konsentrasi Basa';
label2.Caption:='Konstanta Basa (Kb)';
65

label3.Caption:='';
label4.Caption:='';
label5.Caption:='';
edit1.Text:='';
edit2.Text:='';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
ca:=strtofloat(edit1.Text);
ka:=strtofloat(edit2.Text);
d:=sqr(ka)+4*ka*ca;
d1:= sqrt(d);
h1:=(-ka+d1)/2;
h2:=sqrt(ka*ca);
h3:=sqrt(ka*ca+kw);
ph1:=-ln(h1)/ln(10);
ph2:=-ln(h2)/ln(10);
ph3:=-ln(h3)/ln(10);
label3.Caption:='pH = '+floattostr(ph1);
label4.Caption:='pH = '+floattostr(ph2);
label5.Caption:='pH = '+floattostr(ph3);
end else if rg.ItemIndex=1then
begin
cb:=strtofloat(edit1.Text);
kb:=strtofloat(edit2.Text);
d2:=sqr(kb)+4*kb*cb;
d3:= sqrt(d2);
oh1:=(-kb+d3)/2;
oh2:=sqrt(kb*cb);
oh3:=sqrt(kb*cb+kw);
66

poh1:=-ln(oh1)/ln(10);
poh2:=-ln(oh2)/ln(10);
poh3:=-ln(oh3)/ln(10);
ph4:=14-poh1;
ph5:=14-poh2;
ph6:=14-poh3;
label3.Caption:='pH = '+floattostr(ph4);
label4.Caption:='pH = '+floattostr(ph5);
label5.Caption:='pH = '+floattostr(ph6);
end;
end;
end.

67

LATIHAN 19

unit Ulat21;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
68

Edit4: TEdit;
Label6: TLabel;
Edit5: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ca,mla,ka,cb,mlb,h,ph,oh,poh,kb,mva,mvb,ml,cg,c
as,cbs,cgs:real;
const
kw=10e-14;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ca:=strtofloat(edit1.Text);
mla:=strtofloat(edit2.Text);
ka:=strtofloat(edit3.Text);
cb:=strtofloat(edit4.Text);
mlb:=strtofloat(edit5.Text);
mva:=ca*mla;
mvb:=cb*mlb;
ml:=mla+mlb;
if (mva > mvb) then
begin
69

label7.Caption:='Larutan yang terjadi adalah


buffer asam';
cas:=(mva-mvb)/ml;
cg:=mvb/ml;
ph:= (-(ln(ka))/(ln(10)))+(ln(cg)/ln(cas));
label8.Caption:='pH = '+floattostr(ph);
end else if (mva<mvb) then
begin
label7.Caption:='Larutan yang terjadi adalah
sisa basa kuat';
cbs:=(mvb-mva)/ml;
poh:= -(ln(cbs))/(ln(10));
ph:= 14-poh;
label8.Caption:='pH = '+floattostr(ph);
end else if (mva=mvb) then
begin
label7.Caption:='Larutan yang terjadi adalah
garam terhidrolisis';
cgs:=(mvb)/ml;
oh:= sqrt(kw/ka*cgs +kw);
poh:=-((ln(oh))/(ln(10)));
ph:= 14-poh;
label8.Caption:='pH = '+floattostr(ph);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
label7.Caption:='';
label8.Caption:='';
edit1.SetFocus;
end;

70

procedure TForm1.Button3Click(Sender: TObject);


begin
application.Terminate;
end;
end.

71

LATIHAN 20

unit Ulat22;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit1: TEdit;
72

Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button4Click(Sender:
procedure Button1Click(Sender:
procedure Button2Click(Sender:
procedure Button3Click(Sender:
private
{ Private declarations }
public
{ Public declarations }
end;

TObject);
TObject);
TObject);
TObject);

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label2.Visible:=true;
label3.Visible:=true;
label4.Visible:=true;
label5.Visible:=true;
label6.Visible:=true;
label7.Visible:=true;
edit1.Visible:=true;
edit2.Visible:=true;
73

edit3.Visible:=true;
edit4.Visible:=true;
edit5.Visible:=true;
edit6.Visible:=true;
edit1.Text:='Hidrogen';
edit2.Text:='1.00794';
edit3.Text:='1s1';
edit4.Text:='13.598 V';
edit5.Text:='1';
edit6.Text:='20.28 K ';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label2.Visible:=true;
label3.Visible:=true;
label4.Visible:=true;
label5.Visible:=true;
label6.Visible:=true;
label7.Visible:=true;
edit1.Visible:=true;
edit2.Visible:=true;
edit3.Visible:=true;
edit4.Visible:=true;
edit5.Visible:=true;
edit6.Visible:=true;
edit1.Text:='Litium';
edit2.Text:='6.941';
edit3.Text:='[He] 2s1';
edit4.Text:='5.392 V';
edit5.Text:='1';
edit6.Text:='1615 K ';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
label2.Visible:=true;
label3.Visible:=true;
label4.Visible:=true;
74

label5.Visible:=true;
label6.Visible:=true;
label7.Visible:=true;
edit1.Visible:=true;
edit2.Visible:=true;
edit3.Visible:=true;
edit4.Visible:=true;
edit5.Visible:=true;
edit6.Visible:=true;
edit1.Text:='Natrium';
edit2.Text:='22.98977';
edit3.Text:='[He] 3s1';
edit4.Text:='5.139 V';
edit5.Text:='1';
edit6.Text:='1156 K ';
end;
end.

75

LATIHAN 21

unit Ulat23;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label3: TLabel;
Label4: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
76

private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i,n,sum:integer;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label3.Caption:='';
label4.Caption:='';
edit1.Text:='';
edit1.setfocus;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=strtoint(edit1.Text);
sum:=0;
for i:=1 to n do
begin
sum:=sum+sqr(i);
end;
label3.Caption:='Jumlah Kuadrat dari 1 sampai '
+edit1.Text+ ' Adalah';
label4.Caption:=inttostr(sum);
end;
77

end.

78

LATIHAN 22

unit Ulat24;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Memo: TMemo;
Button2: TButton;
Button3: TButton;
79

Button4: TButton;
procedure Button1Click(Sender:
procedure Button2Click(Sender:
procedure Button3Click(Sender:
procedure Button4Click(Sender:
private
{ Private declarations }
public
{ Public declarations }
end;

TObject);
TObject);
TObject);
TObject);

var
Form1: TForm1;
data:array of real;
jml,rata:real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if edit2.Text='' then
messagedlg('Data
belum
diisi',mterror,
[mbok],0)
else
begin
setlength (data,strtoint(edit1.text)+1);
data[strtoint(edit1.text)]:=strtofloat(edit2.text
);
edit1.text:=inttostr(strtoint(edit1.text)+1);
jml:=jml+strtofloat(edit2.Text);
memo.lines.add('Data
ke
'+inttostr(strtoint(edit1.text)-1)+
'
adalah
'
+edit2.text+ ' Jumlah Data = '+ floattostr(jml));
edit2.text:='';
edit2.setfocus;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
80

begin
Rata:=jml/(strtoint(edit1.Text)-1);
memo.Lines.Add('' );
memo.Lines.Add('Rata-rata = '+floattostr(rata));
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text:=inttostr(1);
edit2.text:='';
edit2.setfocus;
jml:=0;
memo.Lines.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
application.Terminate;
end;
end.

81

LATIHAN 23

unit Umid2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
rg: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
82

Edit3: TEdit;
Edit4: TEdit;
Label6: TLabel;
Label7: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure rgClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
oh,ca,va,ka,cb,vb,v,cg,x,alfa,salah,h:real;
const
kw=1e-14;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
ca:=strtofloat(edit1.Text);
va:=strtofloat(edit2.Text);
ka:=strtofloat(edit3.Text);
cb:=strtofloat(edit4.Text);
vb:=(ca*va)/cb;
v:=va+vb;
cg:=(ca*va)/v;
h:=(1e-8);
oh:=kw/h;
x:=(oh-h)/cg;
83

alfa:=h/(h+ka);
salah:=(x-alfa)*100;
label6.caption:='Titrasi berhenti pada pH
label7.caption:='Volume
Basa
dibutuhkan = '+floattostr(vb)+' mL';
label8.caption:='Kesalahan
Titrasi
'+floattostr(salah)+' %';
edit1.SetFocus;
end else if rg.ItemIndex=1 then
begin
ca:=strtofloat(edit1.Text);
va:=strtofloat(edit2.Text);
ka:=strtofloat(edit3.Text);
cb:=strtofloat(edit4.Text);
vb:=(ca*va)/cb;
v:=va+vb;
cg:=(ca*va)/v;
h:=(1e-7);
oh:=kw/h;
x:=(oh-h)/cg;
alfa:=h/(h+ka);
salah:=(x-alfa)*100;
label6.caption:='Titrasi berhenti pada pH
label7.caption:='Volume
Basa
dibutuhkan = '+floattostr(vb)+' mL';;
label8.caption:='Kesalahan
Titrasi
'+floattostr(salah)+' %';;
edit1.SetFocus;
end else if rg.ItemIndex=2 then
begin
ca:=strtofloat(edit1.Text);
va:=strtofloat(edit2.Text);
ka:=strtofloat(edit3.Text);
cb:=strtofloat(edit4.Text);
vb:=(ca*va)/cb;
v:=va+vb;
cg:=(ca*va)/v;
h:=(1e-6);
oh:=kw/h;

8';
yang
=

7';
yang
=

84

x:=(oh-h)/cg;
alfa:=h/(h+ka);
salah:=(x-alfa)*100;
label6.caption:='Titrasi berhenti pada pH 6';
label7.caption:='Volume
Basa
yang
dibutuhkan = '+floattostr(vb)+' mL';;
label8.caption:='Kesalahan
Titrasi
=
'+floattostr(salah)+' %';;
edit1.SetFocus;
end;
end;
procedure TForm1.rgClick(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
label7.caption:='';
label8.caption:='';
label6.caption:='Titrasi berhenti pada pH 8';
edit1.SetFocus;
end else if rg.ItemIndex=1 then
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
label6.caption:='Titrasi berhenti pada pH 7';
label7.caption:='';
label8.caption:='';
edit1.SetFocus;
end else if rg.ItemIndex=2 then
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
85

edit4.Text:='';
label6.caption:='Titrasi berhenti pada pH 6';
label7.caption:='';
label8.caption:='';
edit1.SetFocus;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
end.

86

LATIHAN 24

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, jpeg;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
BEVEL: TBevel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Image1: TImage;
rg2: TRadioGroup;
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
87

procedure rg2Click(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form1.visible:=false;
form2.visible:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.rg2Click(Sender: TObject);
begin
if rg2.ItemIndex=0 then
begin
button1.Enabled:=true;
button2.Enabled:=true;
end else if rg2.ItemIndex=1 then
begin
button2.enabled:=true;
button1.Enabled:=false;
end;
end;
end.
88

unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, shellapi,jpeg,ExtCtrls, ComCtrls,
MPlayer;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
RG: TRadioGroup;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
89

Button8: TButton;
Label1: TLabel;
Image: TImage;
RE: TRichEdit;
StatusBar1: TStatusBar;
Panel1: TPanel;
Button3: TButton;
a1: TButton;
a2: TButton;
a3: TButton;
a4: TButton;
a5: TButton;
g1: TButton;
g2: TButton;
g3: TButton;
g4: TButton;
g5: TButton;
Label2: TLabel;
logo: TImage;
procedure Button1Click(Sender: TObject);
procedure RGClick(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure a1Click(Sender: TObject);
procedure a2Click(Sender: TObject);
procedure a3Click(Sender: TObject);
procedure a4Click(Sender: TObject);
procedure a5Click(Sender: TObject);
procedure g1Click(Sender: TObject);
procedure g2Click(Sender: TObject);
procedure g3Click(Sender: TObject);
procedure g4Click(Sender: TObject);
procedure g5Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
90

private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit3, Unit4, Unit5, Unit6;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm2.RGClick(Sender: TObject);
begin
IF RG.ItemIndex=0 THEN
begin
label1.Caption:='Titrasi Asam-Basa';
logo.Visible:=true;
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
re.Visible:=false;
image.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
a1.Caption:='Animasi Asam 1';
91

a2.Caption:='Animasi Asam 2';


a3.Caption:='Animasi Asam 3';
a4.Caption:='Animasi Asam 4';
a5.Caption:='Animasi Asam 5';
g1.Caption:='Gambar Asam 1';
g2.Caption:='Gambar Asam 2';
g3.Caption:='Gambar Asam 3';
g4.Caption:='Gambar Asam 4';
g5.Caption:='Gambar Asam 5';
END else IF RG.ItemIndex=1 THEN
begin
logo.Visible:=true;
label1.Caption:='Titrasi Redoks';
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
a1.Caption:='Animasi Redoks 1';
a2.Caption:='Animasi Redoks 2';
a3.Caption:='Animasi Redoks 3';
a4.Caption:='Animasi Redoks 4';
a5.Caption:='Animasi Redoks 5';
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
g1.Caption:='Gambar Redoks 1';
g2.Caption:='Gambar Redoks 2';
g3.Caption:='Gambar Redoks 3';
g4.Caption:='Gambar Redoks 4';
g5.Caption:='Gambar Redoks 5';
re.Visible:=false;
image.Visible:=false;
END;
end;
procedure TForm2.Panel1Click(Sender: TObject);
92

begin
aboutbox.showmodal;
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
shellexecute(handle,'open','data/spu.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
shellexecute(handle,'open','data/calc.exe',nil,nil,s
w_show);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
IF RG.ItemIndex=0 THEN
begin
logo.Visible:=false;
image.Visible:=false;
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
re.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
re.Visible:=true;
re.Lines.LoadFromFile('teori/asam-basa.rtf');
END else IF RG.ItemIndex=1 THEN
begin
logo.Visible:=false;
a1.Visible:=false;
93

a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
re.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
image.Visible:=false;
re.Visible:=true;
re.Lines.LoadFromFile('teori/redoks.rtf');
END;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
IF RG.ItemIndex=0 THEN
begin
logo.Visible:=true;
re.Visible:=false;
image.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
a1.Visible:=true;
a2.Visible:=true;
a3.Visible:=true;
a4.Visible:=true;
a5.Visible:=true;
a1.Caption:='Animasi Asam 1';
a2.Caption:='Animasi Asam 2';
a3.Caption:='Animasi Asam 3';
a4.Caption:='Animasi Asam 4';
a5.Caption:='Animasi Asam 5';
94

END else IF RG.ItemIndex=1 THEN


begin
logo.Visible:=true;
image.Visible:=false;
re.Visible:=false;
a1.Visible:=true;
a2.Visible:=true;
a3.Visible:=true;
a4.Visible:=true;
a5.Visible:=true;
a1.Caption:='Animasi Redoks 1';
a2.Caption:='Animasi Redoks 2';
a3.Caption:='Animasi Redoks 3';
a4.Caption:='Animasi Redoks 4';
a5.Caption:='Animasi Redoks 5';
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
END;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
IF RG.ItemIndex=0 THEN
begin
logo.Visible:=true;
image.Visible:=false;
re.Visible:=false;
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
re.Visible:=false;
g1.Visible:=true;
g2.Visible:=true;
g3.Visible:=true;
95

g4.Visible:=true;
g5.Visible:=true;
g1.Caption:='Gambar Asam 1';
g2.Caption:='Gambar Asam 2';
g3.Caption:='Gambar Asam 3';
g4.Caption:='Gambar Asam 4';
g5.Caption:='Gambar Asam 5';
END else IF RG.ItemIndex=1 THEN
begin
logo.Visible:=true;
image.Visible:=false;
re.Visible:=false;
g1.Visible:=true;
g2.Visible:=true;
g3.Visible:=true;
g4.Visible:=true;
g5.Visible:=true;
g1.Caption:='Gambar Redoks 1';
g2.Caption:='Gambar Redoks 2';
g3.Caption:='Gambar Redoks 3';
g4.Caption:='Gambar Redoks 4';
g5.Caption:='Gambar Redoks 5';
END;
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
logo.Visible:=true;
image.Visible:=false;
re.Visible:=false;
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
96

g5.Visible:=false;
IF RG.ItemIndex=0 THEN
begin
form4.visible:=true;
form2.Visible:=false;
END else IF RG.ItemIndex=1 THEN
begin
form5.visible:=true;
form2.Visible:=false;
END;
end;
procedure TForm2.a1Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
if a1.Caption='Animasi Asam 1' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketas1.rtf');
a1.Caption:='Jalankan';
a2.Caption:='Animasi Asam 2';
a3.Caption:='Animasi Asam 3';
a4.Caption:='Animasi Asam 4';
a5.Caption:='Animasi Asam 5';
end else if a1.Caption='Jalankan' then
begin
a1.Caption:='Animasi Asam 1';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Asam1.ex
e',nil,nil,sw_show);
end;
end else if rg.ItemIndex=1 then
begin
if a1.Caption='Animasi Redoks 1' then
begin
image.Visible:=false;
97

re.Visible:=true;
re.lines.LoadFromFile('ket/ketre1.rtf');
a1.Caption:='Jalankan';
a2.Caption:='Animasi Redoks 2';
a3.Caption:='Animasi Redoks 3';
a4.Caption:='Animasi Redoks 4';
a5.Caption:='Animasi Redoks 5';
end else if a1.Caption='Jalankan' then
begin
a1.Caption:='Animasi Redoks 1';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Redoks1.
exe',nil,nil,sw_show);
end;
end;
end;
procedure TForm2.a2Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
if a2.Caption='Animasi Asam 2' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketas2.rtf');
a2.Caption:='Jalankan';
a1.Caption:='Animasi Asam 1';
a3.Caption:='Animasi Asam 3';
a4.Caption:='Animasi Asam 4';
a5.Caption:='Animasi Asam 5';
end else if a2.Caption='Jalankan' then
begin
a2.Caption:='Animasi Asam 2';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Asam2.ex
e',nil,nil,sw_show);
98

end;
end else if rg.ItemIndex=1 then
begin
if a2.Caption='Animasi Redoks 2' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketre2.rtf');
a2.Caption:='Jalankan';
a1.Caption:='Animasi Redoks 1';
a3.Caption:='Animasi Redoks 3';
a4.Caption:='Animasi Redoks 4';
a5.Caption:='Animasi Redoks 5';
end else if a2.Caption='Jalankan' then
begin
a2.Caption:='Animasi Redoks 2';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Redoks2.
exe',nil,nil,sw_show);
end;
end;
end;
procedure TForm2.a3Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
if a3.Caption='Animasi Asam 3' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketas3.rtf');
a3.Caption:='Jalankan';
a2.Caption:='Animasi Asam 2';
a1.Caption:='Animasi Asam 1';
a4.Caption:='Animasi Asam 4';
a5.Caption:='Animasi Asam 5';
end else if a3.Caption='Jalankan' then
99

begin
a3.Caption:='Animasi Asam 3';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Asam3.ex
e',nil,nil,sw_show);
end;
end else if rg.ItemIndex=1 then
begin
if a3.Caption='Animasi Redoks 3' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketre3.rtf');
a3.Caption:='Jalankan';
a2.Caption:='Animasi Redoks 2';
a1.Caption:='Animasi Redoks 1';
a4.Caption:='Animasi Redoks 4';
a5.Caption:='Animasi Redoks 5';
end else if a3.Caption='Jalankan' then
begin
a3.Caption:='Animasi Redoks 3';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Redoks3.
exe',nil,nil,sw_show);
end;
end;
end;
procedure TForm2.a4Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
if a4.Caption='Animasi Asam 4' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketas4.rtf');
a4.Caption:='Jalankan';
100

a2.Caption:='Animasi Asam 2';


a3.Caption:='Animasi Asam 3';
a1.Caption:='Animasi Asam 1';
a5.Caption:='Animasi Asam 5';
end else if a4.Caption='Jalankan' then
begin
a4.Caption:='Animasi Asam 4';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Asam4.ex
e',nil,nil,sw_show);
end;
end else if rg.ItemIndex=1 then
begin
if a4.Caption='Animasi Redoks 4' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketre4.rtf');
a4.Caption:='Jalankan';
a2.Caption:='Animasi Redoks 2';
a3.Caption:='Animasi Redoks 3';
a1.Caption:='Animasi Redoks 1';
a5.Caption:='Animasi Redoks 5';
end else if a4.Caption='Jalankan' then
begin
a4.Caption:='Animasi Redoks 4';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Redoks4.
exe',nil,nil,sw_show);
end;
end;
end;
procedure TForm2.a5Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
101

if a5.Caption='Animasi Asam 5' then


begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketas5.rtf');
a5.Caption:='Jalankan';
a2.Caption:='Animasi Asam 2';
a3.Caption:='Animasi Asam 3';
a4.Caption:='Animasi Asam 4';
a1.Caption:='Animasi Asam 1';
end else if a5.Caption='Jalankan' then
begin
a5.Caption:='Animasi Asam 5';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Asam5.ex
e',nil,nil,sw_show);
end;
end else if rg.ItemIndex=1 then
begin
if a5.Caption='Animasi Redoks 5' then
begin
image.Visible:=false;
re.Visible:=true;
re.lines.LoadFromFile('ket/ketre5.rtf');
a5.Caption:='Jalankan';
a2.Caption:='Animasi Redoks 2';
a3.Caption:='Animasi Redoks 3';
a4.Caption:='Animasi Redoks 4';
a1.Caption:='Animasi Redoks 1';
end else if a5.Caption='Jalankan' then
begin
a5.Caption:='Animasi Redoks 5';
image.Visible:=false;
re.Visible:=false;
shellexecute(handle,'open','aktif/Redoks5.
exe',nil,nil,sw_show);
end;
end;
102

end;
procedure TForm2.g1Click(Sender: TObject);
begin
logo.Visible:=false;
if rg.ItemIndex=0 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Asam1.jp
g');
end else if rg.ItemIndex=1 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Redoks1.j
pg');
end;
end;
procedure TForm2.g2Click(Sender: TObject);
begin
logo.Visible:=false;
if rg.ItemIndex=0 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Asam2.jp
g');
end else if rg.ItemIndex=1 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Redoks2.j
pg');
end;
end;

103

procedure TForm2.g3Click(Sender: TObject);


begin
logo.Visible:=false;
if rg.ItemIndex=0 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Asam3.jp
g');
end else if rg.ItemIndex=1 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Redoks3.j
pg');
end;
end;
procedure TForm2.g4Click(Sender: TObject);
begin
logo.Visible:=false;
if rg.ItemIndex=0 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Asam4.jp
g');
end else if rg.ItemIndex=1 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Redoks4.j
pg');
end;
end;
procedure TForm2.g5Click(Sender: TObject);
begin
104

logo.Visible:=false;
if rg.ItemIndex=0 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Asam5.jp
g');
end else if rg.ItemIndex=1 then
begin
image.Visible:=true;
re.Visible:=false;
image.picture.LoadFromFile('gambar/Redoks5.j
pg');
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
logo.Visible:=true;
image.Visible:=false;
a1.Visible:=false;
a2.Visible:=false;
a3.Visible:=false;
a4.Visible:=false;
a5.Visible:=false;
re.Visible:=false;
g1.Visible:=false;
g2.Visible:=false;
g3.Visible:=false;
g4.Visible:=false;
g5.Visible:=false;
re.Visible:=false;
form2.Visible:=false;
form6.visible:=true;
end;
end.

105

unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, ExtCtrls, ComCtrls;
type
TForm4 = class(TForm)
kembali: TButton;
Keluar: TButton;
re1: TRichEdit;
timer: TTimer;
ket1: TLabel;
ket2: TLabel;
waktu: TLabel;
A: TButton;
B: TButton;
106

C: TButton;
Edit1: TEdit;
pilih: TLabel;
mulai: TButton;
maju: TButton;
kal: TButton;
Label1: TLabel;
spu: TButton;
D: TButton;
Label2: TLabel;
procedure kembaliClick(Sender: TObject);
procedure KeluarClick(Sender: TObject);
procedure mulaiClick(Sender: TObject);
procedure majuClick(Sender: TObject);
procedure AClick(Sender: TObject);
procedure BClick(Sender: TObject);
procedure CClick(Sender: TObject);
procedure timerTimer(Sender: TObject);
procedure kalClick(Sender: TObject);
procedure spuClick(Sender: TObject);
procedure DClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
xb,fni,js,jb,x:integer;
xs,fns,jss,jbs,filename:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm4.kembaliClick(Sender: TObject);
begin
form2.visible:=true;
107

form4.Visible:=false;
js:=1;
jb:=0;
x:=0;
mulai.Visible:=true;
maju.Visible:=false;
ket1.Visible:=false;
ket2.Visible:=false;
re1.visible:=false;
waktu.Visible:=false;
pilih.Visible:=false;
a.Visible:=false;
b.Visible:=false;
c.Visible:=false;
d.Visible:=false;
edit1.Visible:=false;
end;
procedure TForm4.KeluarClick(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm4.mulaiClick(Sender: TObject);
begin
spu.Visible:=true;
label1.Visible:=true;
re1.visible:=true;
waktu.visible:=true;
pilih.visible:=true;
a.visible:=true;
b.visible:=true;
c.visible:=true;
d.Visible:=true;
a.Enabled:=true;
b.Enabled:=true;
108

c.Enabled:=true;
d.Enabled:=true;
ket1.visible:=true;
ket2.visible:=true;
edit1.visible:=true;
maju.visible:=true;
maju.enabled:=true;
kal.visible:=true;
mulai.visible:=false;
filename:='11';
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
js:=1;
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal:'+jss;
jb:=0;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:'+jbs;
timer.Enabled:=true;
x:=0;
end;
procedure TForm4.majuClick(Sender: TObject);
begin
edit1.text:='';
a.Enabled:=true;
b.Enabled:=true;
c.Enabled:=true;
d.Enabled:=true;
re1.visible:=true;
js:=js+1;
fni:=strtoint(filename);
fni:=fni+1;
if fni>20 THEN
fni:=11;
fns:=inttostr(fni);
filename:=fns;
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal: ' +jss;
109

end;

if ket1.Caption='Jumlah Soal: 10' then


maju.Enabled:=false;

procedure TForm4.AClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
110

jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='16' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='17' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='18' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='19' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='20' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
maju.Visible:=false;
end;
end;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

procedure TForm4.BClick(Sender: TObject);


begin
a.Enabled:=false;
111

b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='13' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='14' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='16' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;
112

end else if filename='17' then


begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='18' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='19' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='20' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
maju.Visible:=false;
end;
end;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

procedure TForm4.CClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
113

ket2.Caption:='Jumlah Benar:
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='14' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='15' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='16' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='17' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='18' then
begin

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

114

edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='19' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='20' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
maju.Visible:=false;
end;
end;
procedure TForm4.timerTimer(Sender: TObject);
begin
x:=x+2;
xs:=inttostr(600-x);
waktu.Caption:=xs;
xb:=strtoint(xs);
if xb=0 then
begin
mulai.Enabled:=true;
maju.Enabled:=false;
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
x:=-1;
re1.clear;
timer.Enabled:=false;
waktu.caption:='600';
jb:=0;
115

js:=0;
end;
end;
procedure TForm4.kalClick(Sender: TObject);
begin
shellexecute(handle,'open','data/calc.exe',nil,nil,s
w_show);
end;

procedure TForm4.spuClick(Sender: TObject);


begin
shellexecute(handle,'open','data/spu.exe',nil,nil,sw
_show);
end;
procedure TForm4.DClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Salah';
116

jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='14' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='16' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='17' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='18' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='19' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;
117

end else if filename='20' then


begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
maju.Visible:=false;
end;
end;
end.

unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, ExtCtrls, ComCtrls;
118

type
TForm5 = class(TForm)
timer: TTimer;
Label1: TLabel;
waktu: TLabel;
re1: TRichEdit;
pilih: TLabel;
A: TButton;
B: TButton;
C: TButton;
Edit1: TEdit;
ket1: TLabel;
ket2: TLabel;
maju: TButton;
mulai: TButton;
kembali: TButton;
Keluar: TButton;
kal: TButton;
spu: TButton;
D: TButton;
Label2: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure KeluarClick(Sender: TObject);
procedure kalClick(Sender: TObject);
procedure spuClick(Sender: TObject);
procedure timerTimer(Sender: TObject);
procedure kembaliClick(Sender: TObject);
procedure mulaiClick(Sender: TObject);
procedure AClick(Sender: TObject);
procedure BClick(Sender: TObject);
procedure CClick(Sender: TObject);
procedure majuClick(Sender: TObject);
procedure DClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
119

end;
var
Form5: TForm5;
xb,fni,js,jb,x:integer;
xs,fns,jss,jbs,filename:string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm5.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
form2.visible:=true;
form5.Visible:=false;
end;
procedure TForm5.KeluarClick(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm5.kalClick(Sender: TObject);
begin
shellexecute(handle,'open','data/calc.exe',nil,nil,s
w_show);
end;
procedure TForm5.spuClick(Sender: TObject);
begin
shellexecute(handle,'open','data/spu.exe',nil,nil,sw
_show);
end;
120

procedure TForm5.timerTimer(Sender: TObject);


begin
x:=x+2;
xs:=inttostr(600-x);
waktu.Caption:=xs;
xb:=strtoint(xs);
if xb=0 then
begin
mulai.Enabled:=true;
maju.Enabled:=false;
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
x:=-1;
re1.clear;
timer.Enabled:=false;
waktu.caption:='600';
jb:=0;
js:=0;
end;
end;
procedure TForm5.kembaliClick(Sender: TObject);
begin
form2.visible:=true;
form5.Visible:=false;
js:=1;
jb:=0;
x:=0;
mulai.Visible:=true;
maju.Visible:=false;
ket1.Visible:=false;
ket2.Visible:=false;
re1.visible:=false;
waktu.Visible:=false;
pilih.Visible:=false;
a.Visible:=false;
121

b.Visible:=false;
c.Visible:=false;
d.Visible:=false;
edit1.Visible:=false;
end;
procedure TForm5.mulaiClick(Sender: TObject);
begin
spu.Visible:=true;
label1.Visible:=true;
re1.visible:=true;
waktu.visible:=true;
pilih.visible:=true;
a.visible:=true;
b.visible:=true;
c.visible:=true;
d.Visible:=true;
a.Enabled:=true;
b.Enabled:=true;
c.Enabled:=true;
d.Enabled:=true;
ket1.visible:=true;
ket2.visible:=true;
edit1.visible:=true;
maju.visible:=true;
maju.enabled:=true;
kal.visible:=true;
mulai.visible:=false;
filename:='21';
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
js:=1;
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal:'+jss;
jb:=0;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:'+jbs;
timer.Enabled:=true;
x:=0;
end;
122

procedure TForm5.AClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='21' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='22' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='23' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='24' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='25' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='26' then
begin
123

edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='27' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='28' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='29' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='30' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
maju.Visible:=false;
end;
end;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

procedure TForm5.BClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='21' then
124

begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='22' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='23' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='24' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='25' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='26' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='27' then
begin
edit1.Text:='Salah';
jb:=jb;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

125

jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='28' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='29' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='30' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
maju.Visible:=false;
end ;
end;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

procedure TForm5.CClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='21' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='22' then
begin
edit1.Text:='Benar';
126

jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='23' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='24' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='25' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='26' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='27' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='28' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;
127

end else if filename='29' then


begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='30' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
maju.Visible:=false;
end ;
end;

procedure TForm5.majuClick(Sender: TObject);


begin
edit1.text:='';
a.Enabled:=true;
b.Enabled:=true;
c.Enabled:=true;
d.Enabled:=true;
re1.visible:=true;
js:=js+1;
fni:=strtoint(filename);
fni:=fni+1;
if fni>30 THEN
fni:=21;
fns:=inttostr(fni);
filename:=fns;
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal: ' +jss;
if ket1.Caption='Jumlah Soal: 10' then
maju.Enabled:=false;
end;
128

procedure TForm5.DClick(Sender: TObject);


begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='21' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='22' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='23' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='24' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='25' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='26' then
begin
129

edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='27' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='28' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='29' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='30' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
maju.Visible:=false;
end ;
end;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

'+jbs;

end.

130

unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, shellapi,StdCtrls, ExtCtrls, ComCtrls;
type
TForm6 = class(TForm)
Button1: TButton;
Button2: TButton;
RG: TRadioGroup;
Bevel1: TBevel;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Memo: TMemo;
StatusBar1: TStatusBar;
Label1: TLabel;
Label2: TLabel;
131

Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Panel2: TPanel;
Label5: TLabel;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure RGClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
kw=1e-14;
var
Form6: TForm6;
m,ka,h,ph,oh,kb,ca,cb,mla,mlb,mva,mvb,ml,cas,c
g,poh,cbs,cgs:real;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm6.Button1Click(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;

132

procedure TForm6.Button2Click(Sender: TObject);


begin
form6.Visible:=false;
form2.visible:=true;
memo.Lines.Clear;
label1.Visible:=false;
label2.Visible:=false;
label3.Visible:=false;
label4.Visible:=false;
edit1.Visible:=false;
edit2.Visible:=false;
edit3.Visible:=false;
edit4.Visible:=false;
label5.Visible:=false;
edit5.Visible:=false;
memo.Visible:=false;
end;
procedure TForm6.Button4Click(Sender: TObject);
begin
shellexecute(handle,'open','data/calc.exe',nil,nil,s
w_show);
end;
procedure TForm6.Button5Click(Sender: TObject);
begin
shellexecute(handle,'open','data/spu.exe',nil,nil,sw
_show);
end;
procedure TForm6.RGClick(Sender: TObject);
begin
if rg.ItemIndex=0 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH ASAM LEMAH');
memo.Lines.Add('');
133

label1.Visible:=true;
label1.Caption:='Konsentrasi Asam (M) =';
label2.Visible:=true;
label2.Caption:='Konstanta Asam (Ka) =';
label3.Visible:=false;
label4.Visible:=false;
edit1.Visible:=true;
edit2.Visible:=true;
edit1.Text:='';
edit2.Text:='';
edit3.Visible:=false;
edit4.Visible:=false;
label5.Visible:=false;
edit5.Visible:=false;
end else if rg.ItemIndex=1 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH ASAM KUAT');
memo.Lines.Add('');
label1.Visible:=true;
label1.Caption:='Konsentrasi Asam (M) =';
label2.Visible:=false;
label3.Visible:=false;
label4.Visible:=false;
edit1.Visible:=true;
edit2.Visible:=false;
edit1.Text:='';
edit3.Visible:=false;
edit4.Visible:=false;
label5.Visible:=false;
edit5.Visible:=false;
end else if rg.ItemIndex=2 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH BASA LEMAH');
memo.Lines.Add('');
label1.Visible:=true;
134

label1.Caption:='Konsentrasi Basa (M) =';


label2.Visible:=true;
label2.Caption:='Konstanta Basa (Kb) =';
label3.Visible:=false;
label4.Visible:=false;
edit1.Visible:=true;
edit2.Visible:=true;
edit1.Text:='';
edit2.Text:='';
edit3.Visible:=false;
edit4.Visible:=false;
label5.Visible:=false;
edit5.Visible:=false;
end else if rg.ItemIndex=3 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH BASA KUAT');
memo.Lines.Add('');
label1.Visible:=true;
label1.Caption:='Konsentrasi Basa(M) =';
label2.Visible:=false;
label3.Visible:=false;
label4.Visible:=false;
edit1.Visible:=true;
edit2.Visible:=false;
edit1.Text:='';
edit3.Visible:=false;
edit4.Visible:=false;
label5.Visible:=false;
edit5.Visible:=false;
end else if rg.ItemIndex=4 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH TITRASI ASAM
KUAT DENGAN BASA KUAT');
memo.Lines.Add('');
label1.Visible:=true;
135

label1.Caption:='Konsentrasi Asam (M) =';


label2.Visible:=true;
label2.Caption:='Volume Asam (mL) =';
label3.Visible:=true;
label3.Caption:='Konsentrasi Basa (M) =';
label4.Visible:=true;
label4.Caption:='Volume
Basa
yang
ditambahkan (mL) =';
edit1.Visible:=true;
edit2.Visible:=true;
edit1.Text:='';
edit2.Text:='';
edit3.Visible:=true;
edit4.Visible:=true;
edit3.Text:='';
edit4.Text:='';
label5.Visible:=false;
edit5.Visible:=false;
end else if rg.ItemIndex=5 then
begin
memo.Visible:=true;
memo.Lines.Clear;
memo.Lines.Add('HITUNG pH TITRASI ASAM
LEMAH DENGAN BASA KUAT');
memo.Lines.Add('');
label1.Visible:=true;
label1.Caption:='Konsentrasi Asam (M) =';
label2.Visible:=true;
label2.Caption:='Volume Asam (mL) =';
label3.Visible:=true;
label3.Caption:='Konstanta Asam (Ka) =';
label4.Visible:=true;
label4.Caption:='Konsentrasi Basa (M) =';
label5.Visible:=true;
label5.Caption:='Volume
Basa
yang
ditambahkan (mL) =';
edit5.Visible:=true;
edit5.Text:='';
edit1.Visible:=true;
136

edit2.Visible:=true;
edit1.Text:='';
edit2.Text:='';
edit3.Visible:=true;
edit4.Visible:=true;
edit3.Text:='';
edit4.Text:='';
end;
END;
procedure TForm6.Button3Click(Sender: TObject);
begin
if rg.ItemIndex=0 then
IF (edit1.Text='') or (edit2.Text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
m:=strtofloat(edit1.Text);
ka:=strtofloat(edit2.Text);
h:=sqrt(m*ka);
ph:=-((ln(h))/(ln(10))) ;
memo.Lines.add('pH
larutan
=
'+floattostr(ph));
end else if rg.ItemIndex=1 then
IF (edit1.Text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
m:=strtofloat(edit1.Text);
ph:=-((ln(m))/(ln(10))) ;
memo.Lines.add('pH
larutan
=
'+floattostr(ph));
end else if rg.ItemIndex=2 then
IF (edit1.Text='') or (edit2.Text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
m:=strtofloat(edit1.Text);
kb:=strtofloat(edit2.Text);
137

oh:=sqrt(m*kb);
h:=kw/oh;
ph:=-((ln(h))/(ln(10))) ;
memo.Lines.add('pH
larutan
=
'+floattostr(ph));
end else if rg.ItemIndex=3 then
IF (edit1.Text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
m:=strtofloat(edit1.Text);
h:=kw/m;
ph:=-((ln(h))/(ln(10))) ;
memo.Lines.add('pH
larutan
=
'+floattostr(ph));
end else if rg.ItemIndex=4 then
IF (edit1.Text='') or (edit2.Text='')or (edit3.text='')
or (edit4.text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
ca:=strtofloat(edit1.Text);
mla:=strtofloat(edit2.Text);
cb:=strtofloat(edit3.Text);
mlb:=strtofloat(edit4.Text);
mva:=ca*mla;
mvb:=cb*mlb;
ml:=mla+mlb;
if (mva > mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah sisa asam kuat');
cas:=(mva-mvb)/ml;
ph:= -ln(cas)/ln(10);
memo.lines.add('pH = '+floattostr(ph));
end else if (mva < mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah sisa basa kuat');
138

cbs:=(mvb-mva)/ml;
poh:= -(ln(cbs))/(ln(10));
ph:= 14-poh;
memo.lines.add('pH = '+floattostr(ph));
end else if (mva=mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah garam netral');
memo.lines.add('pH = 7.0');
end;
end else if rg.ItemIndex=5 then
IF (edit1.Text='') or (edit2.Text='')or (edit3.text='')
or (edit4.text='') or (edit5.text='') then
messagedlg('Data
belum
diisi',mterror,
[mbok],0) else
begin
ca:=strtofloat(edit1.Text);
mla:=strtofloat(edit2.Text);
ka:=strtofloat(edit3.Text);
cb:=strtofloat(edit4.Text);
mlb:=strtofloat(edit5.Text);
mva:=ca*mla;
mvb:=cb*mlb;
ml:=mla+mlb;
if (mva > mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah buffer asam');
cas:=(mva-mvb)/ml;
cg:=mvb/ml;
ph:= (-(ln(ka))/(ln(10)))+(ln(cg)/ln(cas));
memo.lines.add('pH = '+floattostr(ph));
end else if (mva<mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah sisa basa kuat');
cbs:=(mvb-mva)/ml;
poh:= -(ln(cbs))/(ln(10));
ph:= 14-poh;
139

memo.lines.add('pH = '+floattostr(ph));
end else if (mva=mvb) then
begin
memo.lines.add('Larutan
yang
terjadi
adalah garam terhidrolisis');
cgs:=(mvb)/ml;
oh:= sqrt(kw/ka*cgs +kw);
poh:=-((ln(oh))/(ln(10)));
ph:= 14-poh;
memo.lines.add('pH = '+floattostr(ph));
end;
end;
end;
end.

unit Unit3;
interface
uses Windows, SysUtils, Classes, Graphics, Forms,
Controls, StdCtrls,
Buttons, ExtCtrls, jpeg;
type
TAboutBox = class(TForm)
Panel1: TPanel;
image: TImage;
label5: TLabel;
140

a: TLabel;
b: TLabel;
c: TLabel;
OKButton: TButton;
d: TLabel;
e: TLabel;
Button1: TButton;
Image1: TImage;
procedure OKButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutBox: TAboutBox;
implementation
{$R *.dfm}
procedure TAboutBox.OKButtonClick(Sender: TObject);
begin
a.Caption:='Version: 1.0';
b.Caption:='Copyright: 2007';
c.Caption:='Comments :Informasi lebih lanjut';
d.Visible:=true;
e.Visible:=true;
close;
end;
procedure TAboutBox.Button1Click(Sender: TObject);
begin
a.Caption:='Kimia Analitik I, UM Press, 2005';
b.Caption:='Buku Teks Analisis Kualitatf Makro dan
Semimikro, 1985';
c.Caption:='http://www.iowa.chemistry';
d.Visible:=false;
e.Visible:=false;
141

end;
end.

142

LATIHAN 25

unit Ugrafikarray;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, Series, TeEngine, StdCtrls, ExtCtrls,
TeeProcs, Chart;
type
TForm1 = class(TForm)
Chart1: TChart;
Chart2: TChart;
Label1: TLabel;
143

Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Series1: TLineSeries;
Series2: TAreaSeries;
procedure Button1Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Data : array of real ;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if edit2.Text='' then
messagedlg('Data
belum
diisi',mtError,
[mbok],0)
else
begin
setlength(data,strtoint(edit1.text)+1);
data[strtoint(edit1.text)]:=
strtofloat(edit2.text);
series1.Add(strtofloat(edit2.text),'',clred);
series2.Add(strtofloat(edit2.text),'',clblue);
memo1.lines.add(edit1.text+'
-->
'+edit2.text);
edit1.text
:=inttostr(strtoint(edit1.text)
+1);
144

edit2.Text
floattostr(strtofloat(edit2.text));
edit2.text :=' ';
edit2.SetFocus;
end;
end;

:=

procedure TForm1.Memo1Change(Sender: TObject);


begin
if edit1.text='11' then
memo1.ScrollBars:=ssVertical;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.terminate;
end;
end.
LATIHAN 26 GRAFIK ARAAY

unit Ugrafikarray;
145

interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, Series, TeEngine, StdCtrls, ExtCtrls,
TeeProcs, Chart;
type
TForm1 = class(TForm)
Chart1: TChart;
Chart2: TChart;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Series1: TLineSeries;
Series2: TAreaSeries;
procedure Button1Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Data : array of real ;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
146

if edit2.Text='' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
setlength(data,strtoint(edit1.text)+1);
data[strtoint(edit1.text)] :=
strtofloat(edit2.text);
series1.Add(strtofloat(edit2.text),'',clred);
series2.Add(strtofloat(edit2.text),'',clblue);
memo1.lines.add(edit1.text+' -->
'+edit2.text);
edit1.text :=inttostr(strtoint(edit1.text)
+1);
edit2.Text :=
floattostr(strtofloat(edit2.text));
edit2.text :=' ';
edit2.SetFocus;
end;
end;
procedure TForm1.Memo1Change(Sender: TObject);
begin
if edit1.text='11' then
memo1.ScrollBars:=ssVertical;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.terminate;
end;
end.

147

LATIHAN 27 GRAFIK FUNGSI

unit Ugrafikfungsi;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, StdCtrls,
Series;
type
TForm1 = class(TForm)
Label1: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Chart1: TChart;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Series1: TLineSeries;
Edit1: TEdit;
Label3: TLabel;
148

procedure RadioButton1Click(Sender: TObject);


procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.RadioButton1Click(Sender:
TObject);
begin
radiobutton1.checked:=true;
radiobutton2.checked:=false;
radiobutton3.checked:=false;
end;
procedure TForm1.RadioButton2Click(Sender:
TObject);
begin
radiobutton2.checked:=true;
radiobutton1.checked:=false;
radiobutton3.checked:=false;
end;
procedure TForm1.RadioButton3Click(Sender:
TObject);
begin
radiobutton3.checked:=true;
radiobutton2.checked:=false;
radiobutton1.checked:=false;
end;
149

procedure TForm1.Button1Click(Sender: TObject);


var i : integer;
Function FX(x : integer):real;
begin
FX:=2*x*x+3*x+5;
end;
Function fs(s:integer):real;
begin
fs:=sin(pi/180*s);
end;
Function fc(c:integer):real;
begin
fc:= cos(pi/180*c)-2*sin(pi/180*c);
end;
begin
series1.Clear;
for i := 1 to strtoint(edit1.text) do
if radiobutton1.Checked then
series1.add(FX(i))
else
if radiobutton2.checked then
series1.add(fs(i))
else
if radiobutton3.checked then
series1.add(fc(i))
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.terminate;
end;
end.

150

LATIHAN 28 DIFERENSIAL NUMERIK (CARA


BACKWARD)

unit Udiferensial1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, Series, TeEngine, ExtCtrls,
TeeProcs, Chart, jpeg;
type
TForm1 = class(TForm)
Label1: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Edit5: TEdit;
151

Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i: integer;
x : real;
Const
dx = 0.0001;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x:real):real;
begin
y := 2*X*X*X + 5*X*X 4*X + 10;
end;
Function dy(x:real):real;
begin
dy := (y(x)-y(x-dx))/dx;
end;
Function d2y(x:real):real;
begin
d2y := (dy(x)-dy(x-dx))/dx;
end;
152

Function d3y(x:real):real;
begin
d3y := (d2y(x)-d2y(x-dx))/dx;
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
x := strtofloat(edit1.Text);
edit2.Text := floattostr(dy(x));
edit3.Text := floattostr(d2y(x));
edit4.Text := floattostr(d3y(x));
edit1.SetFocus;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messageDlg ('Yakin akan keluar?',
mtConfirmation, mbOkCancel,0) = mrOk then
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
edit3.Text := ' ';
edit4.Text := ' ';
edit1.SetFocus;
end;
end.

153

LATIHAN 29 DIFERENSIAL NUMERIK (CARA


FORWARD)

unit Udiferensial1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, Series,
TeEngine, ExtCtrls, TeeProcs, Chart, jpeg;
type
TForm1 = class(TForm)
Label1: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
154

Edit8: TEdit;
Edit9: TEdit;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i: integer;
x : real;
Const
dx = 0.01;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x:real):real;
begin
y := 2*X*X*X + 5*X*X 4*X + 10;
end;
Function dy(x:real):real;
begin
dy := (y(x+dx)-y(x))/dx;
end;
Function d2y(x:real):real;
begin
d2y := (dy(x+dx)-dy(x))/dx;
end;
Function d3y(x:real):real;
155

begin
d3y := (d2y(x+dx)-d2y(x))/dx;
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
x := strtofloat(edit1.Text);
edit2.Text := floattostr(dy(x));
edit3.Text := floattostr(d2y(x));
edit4.Text := floattostr(d3y(x));
edit1.SetFocus;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messageDlg ('Yakin akan
keluar?',mtConfirmation,mbOkCancel,0) = mrOk then
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
edit3.Text := ' ';
edit4.Text := ' ';
edit1.SetFocus;
end;
end.

156

157

LATIHAN 30 DIFERENSIAL NUMERIK (CARA


CENTRAL)

unit Udiferensial1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, Series, TeEngine, ExtCtrls,
TeeProcs, Chart, jpeg;
type
TForm1 = class(TForm)
Label1: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Edit5: TEdit;
158

Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i: integer;
x : real;
Const
dx = 0.01;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x:real):real;
begin
y := 2*X*X*X + 5*X*X 4*X + 10;
end;
Function dy(x:real):real;
begin
dy := (y(x+dx)-y(x-dx))/(2*dx);
end;
Function d2y(y:real):real;
159

begin
end;

d2y := (dy(x+dx)-dy(x-dx))/(2*dx);

Function d3y(x:real):real;
begin
d3y := (d2y(x+dx)-d2y(x-dx))/(2*dx);
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
x := strtofloat(edit1.Text);
edit2.Text := floattostr(dy(x));
edit3.Text := floattostr(d2y(x));
edit4.Text := floattostr(d3y(x));
edit1.SetFocus;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messageDlg ('Yakin akan
keluar?',mtConfirmation,mbOkCancel,0) = mrOk then
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
edit3.Text := ' ';
edit4.Text := ' ';
edit1.SetFocus;
end;
end.

160

LATIHAN 31 DIFERENSIAL NUMERIK DAN GRAFIK


FUNGSI

unit Udiferensial1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, Series, TeEngine, ExtCtrls,
TeeProcs, Chart, jpeg;
type
TForm1 = class(TForm)
Label1: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
161

Image1: TImage;
Label2: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit10: TEdit;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button4: TButton;
Chart1: TChart;
Series1: TLineSeries;
Series2: TBarSeries;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i: integer;
162

tc,Tk,dS,dCp : real;
Const
n = 1;
F = 96485;
dt = 0.1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function E(tc:real):real;
begin
E := 0.23659-4.8564e-4*tc-3.4205e6*tc*tc+5.869e-9*tc*tc*tc;
end;
Function dEf(tc:real):real;
begin
dEf := (E(tc+dt)-E(tc))/dt;
end;
Function d2Ef(tc:real):real;
begin
d2Ef := (dEf(tc+dt)-dEf(tc))/dt;
end;
Function dEb(tc:real):real;
begin
dEb := (E(tc)-E(tc-dt))/dt;
end;
Function d2Eb(tc:real):real;
begin
d2Eb := (dEb(tc)-dEb(tc-dt))/dt;
end;
Function dEc(tc:real):real;
begin
dEc := (E(tc+dt)-E(tc-dt))/(2*dt);
end;
163

Function d2Ec(tc:real):real;
begin
d2Ec := (dEc(tc+dt)-dEc(tc-dt))/(2*dt);
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
tc := strtofloat(edit1.Text);
dS := n*F*dEc(tc);
Tk := tc + 273;
dCp := n*F*Tk*d2Ec(tc);
edit2.Text := floattostr(E(tc));
edit3.Text := floattostr(dEf(tc));
edit4.Text := floattostr(d2Ef(tc));
edit5.Text := floattostr(dEb(tc));
edit6.Text := floattostr(d2Eb(tc));
edit7.Text := floattostr(dEc(tc));
edit8.Text := floattostr(d2Ec(tc));
edit9.Text := floattostr(dS);
edit10.Text := floattostr(dCp);
edit1.SetFocus;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messageDlg ('Yakin akan
keluar?',mtConfirmation,mbOkCancel,0) = mrOk then
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
164

edit3.Text := ' ';


edit4.Text := ' ';
edit5.Text := ' ';
edit6.Text := ' ';
edit7.Text := ' ';
edit8.Text := ' ';
edit9.Text := ' ';
edit10.Text := ' ';
edit1.SetFocus;
end;
procedure TForm1.Button4Click(Sender: TObject);
var i : integer;
Function Ei(i:integer):real;
begin
Ei := 0.23659-4.8564e-4*i-3.4205e6*i*i+5.869e-9*i*i*i;
end;
begin
series1.Clear;
series2.Clear;
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
for i := 1 to 2*strtoint(edit1.text) do
if radiobutton1.Checked then
begin
series1.add(Ei(i))
end else
if radiobutton2.Checked then
begin
series2.add(Ei(i));
end;
end;
end;
procedure TForm1.RadioButton1Click(Sender:
TObject);
165

begin
radiobutton1.checked:=true;
radiobutton2.checked:=false;
end;
procedure TForm1.RadioButton2Click(Sender:
TObject);
begin
radiobutton2.checked:=true;
radiobutton1.checked:=false;
end;
end.

166

LATIHAN 32 AKAR PERSAMAAN (METODE


NEWTON)

unit Unewton;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
167

procedure Button3Click(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
awal, akhir,Xa,Xb : real;
n : integer;
Const
dx = 0.001;
presisi = 1e-5;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x:real) : real;
begin
y :=x*x+ 3*x -10;
end;
Function dy(x:real) : real;
begin
dy :=(y(x)-y(x-dx))/dx;
end;
Procedure Cari_akar(var Xa,Xb : real);
begin
Xb
:= Xa - (y(Xa)/dy(Xa));
awal := Xa;
akhir := Xb;
Xa
:= Xb;
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
Xa := strtofloat(edit1.Text);
168

n := 1;
repeat
Cari_akar(Xa,Xb);
Memo1.Lines.Add(floattostr(awal));
Memo2.Lines.Add(floattostr(akhir));
inc(n,1);
until abs(akhir-awal) <= presisi;
end;
edit1.SetFocus;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
memo1.Clear;
memo2.Clear;
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.

169

LATIHAN 33 AKAR PERSAMAAN (METODE


SECANT)

unit Uakar1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Button3: TButton;
Memo1: TMemo;
Memo2: TMemo;
170

Label7: TLabel;
Label8: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
awal1,awal2, akhir,Xa,Xb, Xc : real;
n : integer;
Const
presisi = 1e-5;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x:real) : real;
begin
y :=x*x+ 3*x -10;
end;
Procedure Cari_akar(var Xa, Xb, Xc : real);
begin
Xc := Xb - ((Xb - Xa)/(y(Xb) - y(Xa)))*y(Xb);
awal1 := Xa;
awal2 := Xb;
akhir := Xc;
Xa
:= Xb;
Xb
:= Xc;
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
171

begin
Xa := strtofloat(edit1.Text);
Xb := strtofloat(edit2.Text);
n := 1;
repeat
Cari_akar(Xa,Xb, Xc);
Memo1.Lines.Add(floattostr(awal2));
Memo2.Lines.Add(floattostr(akhir));
inc(n,1);
until abs(akhir-awal2) <= presisi;
edit1.SetFocus;
end;

end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
memo1.Clear;
memo2.Clear;
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.

172

LATIHAN 34 AKAR PERSAMAAN (VAN DER


WALLS)

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,Dialogs, TeEngine, Series,
StdCtrls, jpeg, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Memo1: TMemo;
173

Memo2: TMemo;
Chart1: TChart;
Image1: TImage;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Label9: TLabel;
Label10: TLabel;
Series1: TAreaSeries;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
p, T, pc, Tc, a, b, awal, akhir,Va,Vb : extended;
n : integer;
Const
dx = 0.001;
presisi = 1e-5; {epsilon}
R = 8.314;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function f(x : extended) : extended;
begin
f :=(p*x*x*x)-((b*p+R*T)*x*x)+(a*x)-(a*b);
end;
Function df(x : extended) : extended;
begin
df := (f(x+dx) - f(x-dx))/(2*dx);
end;
174

Procedure Hitung_abVa;
begin
a
:= (27*sqr(R)*sqr(Tc))/(64*pc);
b := (R*Tc)/(8*pc);
Va := (R*T)/p;
end;
Procedure Newton(var Va,Vb : extended);
begin
Vb := Va - (f(Va)/df(Va));
awal := Va;
akhir := Vb;
Va
:= Vb;
end;
begin
if edit1.Text =' ' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
Tc := strtofloat(edit1.Text);
pc := strtofloat(edit2.Text);
p := strtofloat(edit3.Text);
T := strtofloat(edit4.Text);
Hitung_abVa;
edit5.Text := floattostr(Va);
n := 1;
repeat
Newton(Va,Vb);
Memo1.Lines.Add(floattostr(awal));
Memo2.Lines.Add(floattostr(akhir));
inc(n,1);
until abs(akhir-awal) <= presisi;
edit1.SetFocus;
end;
edit1.SetFocus;
end;
procedure TForm1.Button2Click(Sender: TObject);
var n : integer;
Function fn(n : integer) : extended;
175

begin
fn :=(p*n*n*n)-((b*p+R*T)*n*n)+(a*n)-(a*b);
end;
begin
series1.Clear;
if edit1.Text ='' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
for n := -100 to 100 do
begin
series1.add(fn(n));
end;
end;
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text := ' ';
edit2.Text := ' ';
edit3.Text := ' ';
edit4.Text := ' ';
edit5.Text := ' ';
memo1.Clear;
memo2.Clear;
edit1.SetFocus;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
APPLICATION.Terminate;
end;
end.

176

LATIHAN 35 INTEGRASI NUMERIK (Metode Euler)

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine, Series,
StdCtrls, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Memo1: TMemo;
Memo2: TMemo;
Chart1: TChart;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Series1: TLineSeries;
177

Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
t0, tf, h, sum : real;
N
: integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x : real):real;
begin
y := x;
end;
Procedure Integrasi_Euler;
var h, x : real;
i : integer;
begin
sum := 0;
h := (tf-t0)/N;
x := t0;
sum := sum + y(x)/2;
for i := 1 to N-1 do
begin
x := t0 + i*h;
sum := sum + y(x);
end;
x := tf;
sum := sum + y(x)/2;
sum := sum*h;
Memo1.Lines.Add(Inttostr(N));
Memo2.Lines.Add(floattostr(sum));
178

end;
begin
Memo1.Clear;
Memo2.Clear;
Series1.Clear;
Edit1.SetFocus;
t0:= strtofloat(edit1.Text);
tf:= strtofloat(edit2.Text);
N:= strtoint(edit3.Text);
Integrasi_Euler;
Edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Clear;
Memo2.Clear;
Series1.Clear;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit1.SetFocus;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
function yi(i : integer) : extended;
begin
yi := i;
end;
begin
series1.Clear;
If edit1.Text ='' then
179

messagedlg('Data
[mbok],0)
else
begin
for i := 0 to N do
begin
series1.add(yi(i));
end;
end;
edit1.SetFocus;
end;
end.

belum

diisi',mtError,

180

LATIHAN 36 INTEGRASI NUMERIK (Metode


Simpson)

unit USimpson;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine, Series,
StdCtrls, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Memo1: TMemo;
Memo2: TMemo;
181

Chart1: TChart;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Series1: TLineSeries;
Label7: TLabel;
procedure Button1Click(Sender:
procedure Button3Click(Sender:
procedure Button4Click(Sender:
procedure Button2Click(Sender:
private
{ Private declarations }
public
{ Public declarations }
end;

TObject);
TObject);
TObject);
TObject);

var
Form1: TForm1;
t0, tf, h, sum, sun, luas : real;
N
: integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Function y(x : real):real;
begin
y := x;
end;
Procedure Integrasi_Euler;
var h, x : real;
i : integer;
begin
sum := 0;
h := (tf-t0)/N;
x := t0;
sum := sum + y(x);
i:=1;
repeat
x := t0 + i*h;
182

sum := sum + 4*y(x);


inc(i,2);
until i > n-1;
x := tf;
sum := sum + y(x);
sum := sum*h/3;
sun := 0;
i:=2;
repeat
x := t0 + i*h;
sun := sun + 2*y(x);
inc(i,2);
until i > n-1;
sun:=sun*h/3;
luas:= sun+sum;
Memo1.Lines.Add(Inttostr(N));
Memo2.Lines.Add(floattostr(luas));
end;
begin
Memo1.Clear;
Memo2.Clear;
Series1.Clear;
Edit1.SetFocus;
t0:= strtofloat(edit1.Text);
tf:= strtofloat(edit2.Text);
N:= strtoint(edit3.Text);
Integrasi_Euler;
Edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo1.Clear;
Memo2.Clear;
Series1.Clear;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit1.SetFocus;
183

end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
function yi(i : integer) : extended;
begin
yi := i;
end;
begin
series1.Clear;
if edit1.Text ='' then
messagedlg('Data belum diisi',mtError,
[mbok],0)
else
begin
for i := 0 to N do
begin
series1.add(yi(i));
end;
end;
edit1.SetFocus;
end;
end.

184

LATIHAN 37 DIFFERENSIAL ORDINER

unit URUNGEKUTTA;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls,
ExtCtrls, TeEngine, Series, TeeProcs, Chart;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
185

SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
Bevel1: TBevel;
Bevel2: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label4: TLabel;
Label5: TLabel;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Memo1: TMemo;
Memo2: TMemo;
Chart1: TChart;
Series1: TLineSeries;
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Const
dim=3;
plot=0;
Type mat = array[1..dim] of real;
Var
186

Form1: TForm1;
i,j,N,zat : integer;
t,h,t0,tf,k1,k2,k3,k4,k5 : real;
y,y0,yt,yEuler,m1,m2,m3,m4 : mat;
implementation
{$R *.dfm}
procedure
TForm1.SpeedButton6Click(Sender:
TObject);
Function fx(i:integer; t: real; y: mat): real;
Begin
Case i of
1: fx := -k1*y[1];
2: fx := +k1*y[1]-k2*y[2];
3: fx := +k2*y[2];
end;
end;
Procedure Euler;
var i: integer;
Begin
for i:= 1 to dim do m1[i]:= fx(i,t,y);
for i:= 1 to dim do yEuler[i]:= y[i]+ (h*m1[i]);
for i:= 1 to dim do m2[i]:= fx(i,t+h,yEuler);
for i:= 1 to dim do y[i]:= y[i]+ 0.5*h* (m1[i]+
m2[i]);
for i:= 1 to dim do yt[i]:= y[i]+ j*plot;
if radiobutton1.Checked = true then
begin
Memo1.Visible := false;
Memo2.Visible := false;
Chart1.Visible := true;
series1.Add(yt[zat]);
end;
if radiobutton2.Checked = true then
begin
Chart1.Visible := false;
Series1.Clear;
Memo1.Visible := true;
Memo2.Visible := true;
187

if j <= N/2 then


Memo1.Lines.Add(' '+inttostr(j)+' --> '+
floattostr(yt[zat]))
else
Memo2.Lines.Add(' '+inttostr(j)+' --> '+
floattostr(yt[zat]))
end;
t:= t0 + j*h;

end;
Procedure RungeKutta4;
var i: integer;
Begin
for i:= 1 to dim do m1[i]:= fx(i,t,y);
for i:= 1 to dim do yEuler[i]:= y[i]+
(h*m1[i]/2);
for i:= 1 to dim do m2[i]:= fx(i,t+h/2,yEuler);
for i:= 1 to dim do yEuler[i]:= y[i]+
(h*m2[i]/2);
for i:= 1 to dim do m3[i]:= fx(i,t+h/2,yEuler);
for i:= 1 to dim do yEuler[i]:= y[i]+ (h*m3[i]);
for i:= 1 to dim do m4[i]:= fx(i,t+h,yEuler);
for i:= 1 to dim do y[i]:= y[i]+ (h/6)*(m1[i]+
2*m2[i]+2*m3[i]+m4[i]);
for i:= 1 to dim do yt[i]:= y[i]+ j*plot;
if radiobutton1.Checked = true then
begin
Memo1.Visible := false;
Memo2.Visible := false;
Chart1.Visible := true;
series1.Add(yt[zat]);
end;
if radiobutton2.Checked = true then
begin
Series1.Clear;
Chart1.Visible := false;
Memo1.Visible := true;
Memo2.Visible := true;
if j <= N/2 then
Memo1.Lines.Add(' '+inttostr(j)+'-->'+
188

floattostr(yt[zat]))
else
Memo2.Lines.Add(' '+inttostr(j)+'-->'+
floattostr(yt[zat]))
end;
t:= t0 + j*h;

end;
begin
series1.Clear;
Memo1.Clear;
memo2.Clear;
Edit7.SetFocus;
zat:= strtoint(edit7.Text);
N:= strtoint(edit6.Text);
t0:= 1;
tf:= N;
t := t0;
y0[1]:= strtofloat(Edit1.Text);
y0[2]:= strtofloat(Edit2.Text);
y0[3]:= strtofloat(Edit3.Text);
k1 := StrToFloat(Edit4.Text);
k2 := StrToFloat(Edit5.Text);
y:= y0;
h:= (tf-t0)/N;
for j := 1 to N do
Begin
if radiobutton3.Checked = true then Euler;
if
radiobutton4.Checked
=
true
then
RungeKutta4;
end;
Edit7.SetFocus;
end;
procedure
TForm1.SpeedButton7Click(Sender:
TObject);
begin
APPLICATION.Terminate;
end;
end.
189

190

Potrebbero piacerti anche