Saturday, 21 June 2014
Cara Membuat Program Procedure And Function
PROGRAM PERHITUNGAN
Luas Alas dan Volume Balok
Listing Program di Button Volume:
rocedure TForm1.BVolumeClick(Sender: TObject);
Var LBalok:Integer;begin
EVolume.Text :=VBalok(EPanjang,ELebar,ETinggi,LBalok);
ELuas.Text := IntToStr(LBalok)+' cm2';
end;
procedure TForm1.BResetClick(Sender: TObject);
begin
Reset
end;
procedure TForm1.EPanjangKeyPress(Sender: TObject; var Key: Char);
begin
If Not (Key in ['0'..'9',#8,#13])then Key:=#0;
end;
procedure TForm1.btnkeluarClick(Sender: TObject);
begin
halt;
end;
Listing Program di Button Reset :
procedure TForm1.BResetClick(Sender: TObject);
beginReset
end;
procedure TForm1.EPanjangKeyPress(Sender: TObject; var Key: Char);
begin
If Not (Key in ['0'..'9',#8,#13])then Key:=#0;
end;
procedure TForm1.btnkeluarClick(Sender: TObject);
begin
halt;
end;
Listing Program di Button Keluar:
procedure TForm1.btnkeluarClick(Sender: TObject);
beginhalt;
end;
Friday, 20 June 2014
Cara Membuat Program "Mengurutkan Data"
PROGRAM MENGURUTKAN DATA
Listing Program Mengurutkan Data :
program Program_mengurutkandata;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
deret : array[1..100] of integer;
loop, nested, banyak, tampung : integer;
begin
write ('Berapa banyak bilangan yang ingin diurutkan ? = ');
readln (banyak);
for loop := 1 to banyak do
begin
write ('Bilangan ke ',loop:3,' = ');
readln (deret[loop]) ;
end;
for loop := 1 to banyak -1 do
for nested := loop +1 to banyak do
if (deret[nested]< deret[loop]) then
begin
tampung:= deret[nested];
deret[nested]:= deret[loop];
deret[loop]:= tampung
end;
writeln;
writeln('Hasil pengurutan bilangan dari besar ke kecil');
for loop:= banyak downto 1 do
begin
writeln ('Data ke ', (banyak- loop+1):3, '=', deret[loop]);
end;
read;
writeln;
writeln('Program Mengurutkan Data, by : Ferry Noer Zahrie 2A') ;
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
begin
{ TODO -oUser -cConsole Main : Insert code here }
end.
Cara Membuat Program Array
PROGROM ARRAY
Buat Form seperti di atas..
Listing Program Untuk Button Input:
procedure TForm1.btninputClick(Sender: TObject);
Var i:integer;
Nama1,nama2 :array[1..5] of string;
S: string;
begin
s:= inputbox('Input Data','Masukkan Jumlah Data :','0');
for i:= 1 to strtoint(s) do
begin
nama1[i]:= inputbox('Data Ke:'+inttostr(i),'Nama Awal',' ');
nama2[i]:= inputbox('Data Ke:'+inttostr(i),'Nama Belakang',' ');
Lbdata.ITEMS.ADD(NAMA1[I]+ ' ' +NAMA2[I]);
EDIT1.Text:= INTTOSTR (Lbdata.Items.COUNT);
END;
end;
Var i:integer;
Nama1,nama2 :array[1..5] of string;
S: string;
begin
s:= inputbox('Input Data','Masukkan Jumlah Data :','0');
for i:= 1 to strtoint(s) do
begin
nama1[i]:= inputbox('Data Ke:'+inttostr(i),'Nama Awal',' ');
nama2[i]:= inputbox('Data Ke:'+inttostr(i),'Nama Belakang',' ');
Lbdata.ITEMS.ADD(NAMA1[I]+ ' ' +NAMA2[I]);
EDIT1.Text:= INTTOSTR (Lbdata.Items.COUNT);
END;
end;
Listing Program Untuk Button Clear:
procedure TForm1.btnclearClick(Sender: TObject);
begin
Lbdata.clear;
EDIT1.Text:=' ';
end;
begin
Lbdata.clear;
EDIT1.Text:=' ';
end;
Listing Program Untuk Button
procedure TForm1.btncloseClick(Sender: TObject);
begin
halt;
end;
begin
halt;
end;
Subscribe to:
Posts
(
Atom
)