Lihat ScreenShoot lainnya di bawah
program Data_Parkir;
{I.S : User memilih menu pada program}
{F.S : Menampilkan data parkir}
uses crt;
const
Maks_data = 5;
type
Parkiran = record
Kode,Jenis,Tanggal : string;
H1,M1,H2,M2 : integer;
jam,Biaya,Sisa : real;
end; // endrecord
Parkir = array[1..Maks_data]
of Parkiran;
var
PK : Parkir;
Menu : integer;
//function hasil
Function Hasil (H1,H2,M1,M2 : integer) : real;
{I.S : Jam dan menit sudah terdefinisi}
{F.S : Menghasilkan fungsi hasil}
var
Masuk,Keluar : integer;
begin
Masuk := (H1 * 3600) + (M1 * 60);
Keluar := (H2 * 3600) + (M2 *
60);
Hasil := Keluar - Masuk;
end; // End Function
function Harga (jam : real) : real;
{I.S : Jam sudah terdefinisi}
{F.S : Menghasilkan fungsi harga}
begin
if (jam >= 0) and (jam
<= 1)
then
begin
Harga := 1000;
end
else
if (jam >= 1) and (jam
<= 2)
then
begin
Harga := 2000;
end
else
if (jam > 2) and
(jam <= 3)
then
begin
Harga := 3000;
end
else
if (jam > 3)
and (jam <= 4)
then
begin
harga :=
4000;
end
else
if (jam >
4) and (jam <= 5)
then
begin
harga :=
5000;
end
else
begin
harga :=
6000;
end;//
endif
end; // endfunction
//procedure isi data
procedure Isi_Data (var PK : Parkir);
{I.S : User memasukan Tanggal_Parkir,Kode Kendaraan,Jenis Kendraan,Jam
Masuk dan Jam Keluar}
{F.S : Menghasilkan data parkir}
var
i : integer;
begin
//memasukan banyaknya data
clrscr;
gotoxy
(1,24);textbackground(1);
gotoxy(25,2); write('DATA
PARKIR KENDARAAN');
gotoxy(1,4);
writeln('--------------------------------------------------------------------');
gotoxy(1,5);
writeln('| No | Tanggal
| Kode | Jenis | Jam Masuk | Jam Keluar |');
gotoxy(1,6);
writeln('| |
Parkir | Kendaraan | Kendaraan
| | |');
gotoxy(1,7);
writeln('--------------------------------------------------------------------');
// Baris Selanjutnya
for i := 1 to maks_data do
begin
gotoxy(1,i+7);
writeln('| |
| | |
: | :
|');
gotoxy(3,i+7); write(i);
gotoxy(8,i+7); readln(PK[i].Tanggal);
gotoxy(21,i+7);
readln(PK[i].Kode);
gotoxy(33,i+7);
readln(PK[i].Jenis);
gotoxy(46,i+7);
readln(PK[i].H1);
while (PK[i].H1 > 24) or
(PK[i].H1 < 0) do
begin
gotoxy(46,i+8);write('Angka harus dari 1 sampai 24');
readln;
gotoxy(46,i+8);clreol;
gotoxy(46,i+7);clreol;
gotoxy(43,i+7);write('| : |
: |');
gotoxy(46,i+7);
readln(PK[i].H1);
end; //endwhile
gotoxy(51,i+7);
readln(PK[i].M1);
while (PK[i].M1 > 60) or
(PK[i].M1 < 0) do
begin
gotoxy(46,i+8);write('Angka harus dari 1 sampai 60');
readln;
gotoxy(46,i+8);clreol;
gotoxy(51,i+7);clreol;
gotoxy(51,i+7);write(' | :
|');
gotoxy(51,i+7);
readln(PK[i].M1);
end; //endwhile
gotoxy(58,i+7);
readln(PK[i].H2);
while (PK[i].H2 > 24) or
(PK[i].H2 < 0) do
begin
gotoxy(38,i+8);write('Angka harus dari 1 sampai 24');
readln;
gotoxy(38,i+8);clreol;
gotoxy(56,i+7);clreol;
gotoxy(55,i+7);write('| : |');
gotoxy(58,i+7);
readln(PK[i].H2);
end; //endwhile
gotoxy(63,i+7);
readln(PK[i].M2);
while (PK[i].M2 > 60) or
(PK[i].M2 < 0) do
begin
gotoxy(38,i+8);write('Angka harus dari 1 sampai 60');
readln;
gotoxy(38,i+8);clreol;
gotoxy(63,i+7);clreol;
gotoxy(63,i+7);write(' |');
gotoxy(63,i+7);
readln(PK[i].M2);
end; //endwhile
if (i mod 2 = 0)then
textbackground(1)
else
textbackground(3);
end; // endfor
// Garis Penutup
if (i = maks_data) then
begin
gotoxy(1,i+8);
write('--------------------------------------------------------------------');
end; //endif
readln;
end; // end procedure
procedure Cari_Kode (PK : Parkir);
{I.S : Data parkir sudah terdefinisi}
{F.S : Menampilkan data yang dicari}
var
i,No,j : integer;
Kode_Cari : string;
ketemu : boolean;
begin
clrscr;
//memasukkan angka yang di cari
write ('Kode yang di cari : ');
readln(Kode_Cari);
//inisialisasi harga i
i := 1;
//inisialisasi variable boolean
Ketemu := false;
//proses searching
while (not Ketemu) and (i <=
Maks_data) do
begin
if (PK[i].Kode = Kode_Cari)
then
Ketemu := true
else
i := i + 1;
end; // endwhile
//menampilkan kode
if (ketemu)
then
begin
clrscr;
gotoxy (1,1);
writeln('Kode yang di cari
: ',Kode_Cari);
gotoxy(35,3); write('DATA
PARKIR');
gotoxy(1,4);
writeln('-------------------------------------------------------------------------------');
gotoxy(1,5);
writeln('| No | Tanggal
| Kode | Jenis | Jam Masuk | Jam Keluar | Biaya
|');
gotoxy(1,6);
writeln('| |
Parkir | Kendaraan | Kendaraan
| | |
Parkir |');
gotoxy(1,7);
writeln('-------------------------------------------------------------------------------');
No := 0;
for j := i to maks_data do
begin
if (PK[j].Kode =
Kode_Cari)
then
begin
No := No + 1;
gotoxy(1,No+7);
writeln('| |
| | |
: | :
| Rp. |');
gotoxy(3,No+7); write(j);
gotoxy(8,No+7);
write(PK[j].Tanggal);
gotoxy(21,No+7);
write(PK[j].Kode);
gotoxy(33,No+7);
write(PK[j].Jenis);
gotoxy(46,No+7);
write(PK[j].H1);
gotoxy(51,No+7);
write(PK[j].M1);
gotoxy(58,No+7);
write(PK[j].H2);
gotoxy(63,No+7);
write(PK[j].M2);
PK[j].sisa :=
Hasil(PK[j].H1,PK[j].H2,PK[j].M1,PK[j].M2);
PK[j].Jam :=
PK[j].Sisa/3600;
PK[j].Biaya :=
Harga(PK[j].jam);
gotoxy(74,No+7);
write(PK[j].Biaya:0:0);
end; // endif
end; // endfor
gotoxy(1,No+8);
write('-------------------------------------------------------------------------------');
end
else
write(Kode_Cari,' Tidak
Ditemukan');
readln;
end; // end procedure
procedure Cari_Nama (PK : Parkir);
{I.S : Data parkir sudah terdefinisi}
{F.S : Menampilkan data yang dicari}
var
i,No,j : integer;
Nama_Cari : string;
Ketemu : boolean;
begin
clrscr;
//memasukkan angka yang di cari
write ('Nama yang di cari : ');
readln(Nama_Cari);
//inisialisasi harga i
i := 1;
//inisialisasi variable boolean
Ketemu := false;
//proses searching
while (not Ketemu) and (i <=
Maks_data) do
begin
if (PK[i].Jenis =
Nama_Cari)
then
Ketemu := true
else
i := i + 1;
end; // endwhile
//menampilkan kode
if (ketemu)
then
begin
clrscr;
gotoxy (1,1);
writeln('Nama yang di
cari : ',Nama_Cari);
gotoxy(35,3); write('DATA
PARKIR');
gotoxy(1,4);
writeln('-------------------------------------------------------------------------------');
gotoxy(1,5);
writeln('| No | Tanggal
| Kode | Jenis | Jam Masuk | Jam Keluar | Biaya
|');
gotoxy(1,6);
writeln('| |
Parkir | Kendaraan | Kendaraan
| | |
Parkir |');
gotoxy(1,7);
writeln('-------------------------------------------------------------------------------');
No := 0;
for j := i to maks_data
do
begin
if (PK[j].Jenis =
Nama_Cari)
then
begin
No := No + 1;
gotoxy(1,No+7);
writeln('| |
| | |
: | :
| Rp. |');
gotoxy(3,No+7); write(j);
gotoxy(8,No+7);
write(PK[j].Tanggal);
gotoxy(21,No+7);
write(PK[j].Kode);
gotoxy(33,No+7);
write(PK[j].Jenis);
gotoxy(46,No+7);
write(PK[j].H1);
gotoxy(51,No+7);
write(PK[j].M1);
gotoxy(58,No+7);
write(PK[j].H2);
gotoxy(63,No+7);
write(PK[j].M2);
PK[j].sisa :=
Hasil(PK[j].H1,PK[j].H2,PK[j].M1,PK[j].M2);
PK[j].Jam :=
PK[j].Sisa/3600;
PK[j].Biaya :=
Harga(PK[j].jam);
gotoxy(74,No+7);
write(PK[j].Biaya:0:0);
end; // endif
end; // endfor
gotoxy(1,No+8);
write('-------------------------------------------------------------------------------');
end
else
write(Nama_Cari,' Tidak
Ditemukan');
readln;
end; // endprocedure
procedure Cari_Harga (PK : Parkir);
{I.S : Data parkir sudah terdefinisi}
{F.S : Menampilkan data yang dicari}
var
i,No,j : integer;
Harga_Cari : real;
Ketemu : boolean;
begin
clrscr;
//memasukan angka yang di cari
write ('Harga yang di cari :
'); readln(Harga_Cari);
//inisialisasi harga i
i := 1;
//inisialisasi variable boolean
Ketemu := false;
//proses searching
while (not Ketemu) and (i <=
Maks_data) do
begin
if (PK[i].Biaya =
Harga_Cari)
then
Ketemu := true
else
i := i + 1;
end; // endwhile
//menampilkan kode
if (ketemu)
then
begin
clrscr;
gotoxy (1,1);
writeln('Harga yang di cari
: ',Harga_Cari:0:0);
gotoxy(35,3); write('DATA
PARKIR');
gotoxy(1,4);
writeln('-------------------------------------------------------------------------------');
gotoxy(1,5);
writeln('| No | Tanggal
| Kode | Jenis | Jam Masuk | Jam Keluar | Biaya
|');
gotoxy(1,6);
writeln('| |
Parkir | Kendaraan | Kendaraan
| | |
Parkir |');
gotoxy(1,7);
writeln('-------------------------------------------------------------------------------');
No := 0;
for j := i to maks_data do
begin
if (PK[j].Biaya =
Harga_Cari)
then
begin
No := No + 1;
gotoxy(1,No+7);
writeln('| |
| | |
: | :
| Rp. |');
gotoxy(3,No+7); write(j);
gotoxy(8,No+7);
write(PK[j].Tanggal);
gotoxy(21,No+7);
write(PK[j].Kode);
gotoxy(33,No+7);
write(PK[j].Jenis);
gotoxy(46,No+7);
write(PK[j].H1);
gotoxy(51,No+7);
write(PK[j].M1);
gotoxy(58,No+7);
write(PK[j].H2);
gotoxy(63,No+7); write(PK[j].M2);
PK[j].sisa :=
Hasil(PK[j].H1,PK[j].H2,PK[j].M1,PK[j].M2);
PK[j].Jam :=
PK[j].Sisa/3600;
PK[j].Biaya :=
Harga(PK[j].jam);
gotoxy(74,No+7);
write(PK[j].Biaya:0:0);
end; // endif
end; // endfor
gotoxy(1,No+8);
write('-------------------------------------------------------------------------------');
end
else
write(Harga_Cari:0:0,'
Tidak Ditemukan');
readln;
end; // endprocedure
procedure Urut_Kode (var PK : Parkir);
{I.S : Data parkir sudah terdefinisi}
{F.S : Menampilkan data yang telah terurut}
var
i,j : integer;
temp : Parkiran;
begin
for i := 1 to maks_data-1 do
begin
for j := maks_data downto
(i+1) do
begin
if (PK[j].Kode <
PK[j-1].Kode)
then
begin
temp := PK[j];
PK[j] := PK[j-1];
PK[j-1] := temp;
end; //endif
end; //endfor
end; //endfor
end; // endprocedure
//procedure tampil data
Procedure Tampil_Data (var PK : Parkir);
{I.S : Data parkir sudah terdefinisi}
{F.S : Menampilkan data yang dicari}
var
i : integer;
begin
window(1,1,80,24);textbackground(black);
gotoxy
(1,24);textbackground(1);
Urut_Kode (PK);
clrscr;
gotoxy(35,2); write('DATA
PARKIR');
gotoxy(1,4);
writeln('-------------------------------------------------------------------------------');
gotoxy(1,5);
writeln('| No | Tanggal
| Kode | Jenis | Jam Masuk | Jam Keluar | Biaya
|');
gotoxy(1,6);
writeln('| |
Parkir | Kendaraan | Kendaraan
| | |
Parkir |');
gotoxy(1,7);
writeln('-------------------------------------------------------------------------------');
//baris selanjutnya
for i := 1 to maks_data do
begin
if (i mod 2 = 0)
then
textbackground(3)
else
textbackground(1);
gotoxy(1,i+7);
writeln('|
| | | |
: | :
| Rp. |');
gotoxy(3,i+7); write(i);
gotoxy(8,i+7); write(PK[i].Tanggal);
gotoxy(21,i+7);
write(PK[i].Kode);
gotoxy(33,i+7); write(PK[i].Jenis);
gotoxy(46,i+7);
write(PK[i].H1);
gotoxy(51,i+7);
write(PK[i].M1);
gotoxy(58,i+7);
write(PK[i].H2);
gotoxy(63,i+7);
write(PK[i].M2);
PK[i].sisa :=
Hasil(PK[i].H1,PK[i].H2,PK[i].M1,PK[i].M2);
PK[i].Jam :=
PK[i].Sisa/3600;
PK[i].Biaya :=
Harga(PK[i].jam);
gotoxy(74,i+7);
write(PK[i].Biaya:0:0);
end; //endfor
//garis Penutup
gotoxy(1,i+8);
write('-------------------------------------------------------------------------------');
readln;
end; //end procedure
procedure Menu_Pilihan (var Menu : integer);
{I.S : User memilih menu pilihan}
{F.S : Menampilkan menu yang dipilih}
begin
clrscr;
gotoxy(24,7 ); write
('<============Menu============>');
gotoxy(24,8 ); write ('| 1. Isi Data |');
gotoxy(24,9 ); write ('| 2. Cari berdasarkan kode |');
gotoxy(24,10); write ('| 3. Cari berdasarkan nama |');
gotoxy(24,11 ); write ('| 4.
Cari berdasarkan harga |');
gotoxy(24,12); write ('| 5. Tampil data |');
gotoxy(24,13); write ('| 0. Keluar |');
gotoxy(24,14); write
('<============================>');
gotoxy(24,16); write ('Pilihan Anda : '); readln(Menu);
end; //endprocedure
//program utama
begin
repeat
window(1,1,80,24);textbackground(black);
Menu_Pilihan (Menu);
case Menu of
1 : Isi_Data(PK);
2 : Cari_Kode(PK);
3 : Cari_Nama(PK);
4 : Cari_Harga(PK);
5 : Tampil_Data(PK);
0 : Exit;
end; // endcaseof
until (Menu = 0);
readln;
end.
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
Download Scriptnya :
catatan :
hargailah tulisan orang lain, jika anda mengcopy-paste harap cantumkan link sumber.
0 komentar