Jam Kita

Minggu, 15 Mei 2011

CONTOH ARRAY DALAM PASCAL

program PDAM;
uses wincrt;
var
   nama, alamat : array [1..10] of string;
   pemakaian    : array [1..10] of integer;
   golongan      : array [1..10] of char;
   total             : integer;
   bayar           : array [1..10] of integer;
   n,j                : byte;
   lagi              : char;
   tarif,sewa    : array [1..10] of integer;

begin
clrscr;
lagi:='y';
n:=0;
while (lagi='y') or (lagi='Y') do
begin
     clrscr;
     n:=n+1;
     write('nama langganan ke ',n,'     :'); readln(nama[n]);
     write('alamat langganan ke ',n,'   :'); readln(alamat[n]);
     write('golongan (A,B,C) ke ',n,'   :'); readln(golongan[n]);
     write('pemakaian ke ',n,'          :'); readln(pemakaian[n]);
     write('masih ada data lagi...???   :'); readln(lagi)
end;

begin
writeln('Daftar Pembayaran Langganan PDAM Bulan Januari 2011');
clrscr;

gotoxy (20,2); writeln('Daftar Pembayaran');
gotoxy (5,5); writeln('=============================================================');
gotoxy (5,6); writeln('|no|    nama     |   alamat     | golongan | pemakaian |  bayar |');
gotoxy (5,7); writeln('|    | langganan | langganan  |               |     (m3)      |            |');
gotoxy (5,8); writeln('=============================================================');
total:=0;
for j:=1 to n do


begin
gotoxy (5,8+j); writeln('|');
gotoxy (6,8+j); writeln (j);
gotoxy (8,8+j); writeln ('|');
gotoxy (10,8+j); writeln (nama[j]);
gotoxy (20,8+j); writeln ('|');
gotoxy (23,8+j); writeln(alamat[j]);
gotoxy (33,8+j); writeln('|');
gotoxy (39,8+j); writeln(golongan[j]);
gotoxy (44,8+j); writeln('|');
gotoxy (47,8+j); writeln(pemakaian[j]);
gotoxy (56,8+j); writeln('|');


case upcase (golongan[j]) of
'A'  : begin
             tarif[j]:=300; sewa[j]:=5000;
       end;
'B'  : begin
             tarif[j]:=250; sewa[j]:=3500;
       end;
'C'  : begin
             tarif[j]:=175; sewa[j]:=2500;
       end;
end;
bayar[j]:=(pemakaian[j]*tarif[j])+sewa[j];
total:=total+bayar[j];

gotoxy (58,8+j); writeln(bayar[j]);
gotoxy (65,8+j); writeln('|');
end;

gotoxy (5,9+j); writeln('=============================================================');

gotoxy (5,10+j); writeln('|');
gotoxy (33,10+j); writeln('TOTAL');
gotoxy (56,10+j); writeln('|');
gotoxy (58,10+j); writeln(total);
gotoxy (65,10+j); writeln('|');

gotoxy (5,11+j); writeln('=============================================================');
end;
end.

1 komentar:

  1. Betway Casino » 10 Free Spins No Deposit! | Mapyro
    Sign up 부산광역 출장안마 at Betway 오산 출장마사지 and play with 10+ Casino games 의왕 출장마사지 for free or 천안 출장샵 real money - No download required. 경상남도 출장마사지

    BalasHapus