Tuesday, March 10, 2015

Program Pointer Pada Pemrograman Pascal

Pointer merupakan suatu tipe data dalam Pascal yang berfungsi untuk menunjuk dan menyimpan alamat memori. Dalam penulisan pointer biasa digambar dengan panah, sedangkan bagian memori yang ditunjuk digambar dengan kotak, dan isinya ditulis di dalam kotak.
Berikut ini Programnya :


Source code
Uses Crt ;
Type
Petunjuk_sewa = ^Data_sewa ;
Data_sewa = Record
     kode: byte;
     Nama : String[25] ;
     mobil:string;
     lama:byte;
     harga:real;
     bayar:real;
End ;
Var
Data_sewax : Array[1..20] of Petunjuk_sewa;
                i, j, n : Byte ;

Begin
clrscr;
writeln;
writeln('         TABEL JENIS MOBIL DAN HARGA SEWA');
writeln(' +==============================================+');
writeln(' | Kode Mobil | Jenis Mobi     |   Harga Sewa   |');
writeln(' +------------+----------------+----------------+');
writeln(' |     1      | Toyota Corolla |  Rp. 450.000,- |');
writeln(' |     2      | Toyota Soluna  |  Rp. 350.000,- |');
writeln(' |     3      | Toyota Vios    |  Rp. 350.000,- |');
writeln(' |     4      | Toyota Camry   |  Rp. 550.000,- |');
writeln(' |     5      | Toyota Altis   |  Rp. 450.000,- |');
writeln(' +==============================================+');
writeln;
Write('Banyaknya Data Penyewaan: ') ;readLn(n);
For i := 1 to n do
                Begin
                Writeln;
                Writeln('Data Penyewa ke=>',i:2);
                New(Data_sewax[i]) ;
                With Data_sewax[i]^ do
                                Begin

                                Write('Kode Mobil       : ');readLn(kode) ;
                                                if (kode=1) then

                                                                begin
                                                                mobil:='Toyota Corolla';
                                                                harga:=450000;
                                                                end
                                                else if (kode=2) then
                                                                begin
                                                                mobil:='Toyota Soluna';
                                                                harga:=350000;
                                                                end
                                                else if (kode=3) then
                                                                begin
                                                                mobil:='Toyota Vios';
                                                                harga:=350000;
                                                                end
                                                else if (kode=4) then
                                                                begin
                                                                mobil:='Toyota Camry';
                                                                harga:=550000;
                                                                end
                                                else if (kode=5) then
                                                                begin
                                                                mobil:='Toyota Altis';
                                                                harga:=450000;
                                                                end;



                                Write('Lama Peminjaman  : ');readLn(lama);
                                bayar:=lama*harga;
                                Write('Nama Peminjam    : ');readLn(Nama) ;
                writeln;
                writeln('Jenis Mobil      : ',mobil);
                writeln('Harga Sewa       : Rp. ',harga:6:2,' per hari');
                                writeln('Total Pembayaran : Rp. ' ,bayar:9:2);
                                readln;
                                End ;
                End ;

ClrScr;
writeln;
WriteLn('                                DATA PENYEWAAN MOBIL') ;
WriteLn('+-----------------------------------------------------------------------------+') ;
WriteLn('| No.|    Nama  |   Jenis Mobil  | Lama Pinjam |  Harga Sewa  |  Total Bayar  |') ;
WriteLn('+-----------------------------------------------------------------------------+') ;
For i := 1 to n do
With Data_sewax[i]^ do
Writeln('|',i:3,' | ',nama:8,' | ',mobil:14,' | ',lama:6,' hari | Rp ',harga:9:2,' | Rp ',bayar:10:2,' |');
WriteLn('+-----------------------------------------------------------------------------+') ;
readln;
end.

Hasil Program
Tampilan Runing Program

Hasil Runing Program


Demikian artikel tentang Program Pointer Pada Pemrograman Pascal.
baca juga artikel tentang program quicjk sort dipemrograman pascal

No comments:

Post a Comment