Pemkaian Fungsi Array pada turbo paskal "Menghitung Penjualan Barang"
uses crt;
var
i,m:integer;
kd_brg,nama_brg:array[1..10] of string;
harga,tharga:array[1..10] of longint;
jumlah:array[1..10] of integer;
diskon,tbayar:array[1..10] of real;
begin
clrscr;
write('Masukkan Jumlah Barang :');readln(m);
writeln('=====================');
for i:=1 to m do
begin
write ('Kode Barang[',i,']:');readln (kd_brg[i]);
if (kd_brg[i]='AOO1') or (kd_brg[i]='aoo1') then
begin
nama_brg[i]:='meja';
harga[i]:=75000;
end
else if (kd_brg[i]='AOO2') or (kd_brg[i]='aoo2') then
begin
nama_brg[i]:='lemari';
harga[i]:=2500000;
end
else if (kd_brg[i]='AOO3') or (kd_brg[i]='aoo3') then
begin
nama_brg[i]:='Kulkas';
harga[i]:=3000000;
end
else
begin
nama_brg[i]:='Kursi';
harga[i]:=450000
end;
writeln ('Nama Barang[',i,']:');readln(nama_brg[i]);
writeln ('Harga Barang[',i,']:');readln(harga[i]);
writeln ('Jumlah Beli[',i,']:');readln(jumlah[i]);
tharga[i]:=harga[i]*jumlah[i];
if (jumlah[i] >=1) and (jumlah[i] <=5) then
diskon[i]:=0.02*harga[i]
else if (jumlah[i] >=6) and (jumlah[i] <=10) then
diskon[i]:=0.04*harga[i]
else
diskon[i]:=0.05*harga[i];
tbayar[i]:=tharga[i]-diskon[i];
writeln ('Total Harga[',i,']:',tharga[i]);
writeln ('Diskon[',i,']:',diskon[i]:0:2);
writeln ('Total Bayar[',i,']:',tbayar[i]:0:2);
writeln;
end;
clrscr;
writeln ('=============================');
gotoxy (1,2);writeln ('No');
gotoxy (5,2);writeln ('Kode Barang');
gotoxy (18,2);writeln ('Nama Barang');
gotoxy (31,2);writeln ('Harga');
gotoxy (40,2);writeln ('Jumlah');
gotoxy (47,2);writeln ('Diskon');
gotoxy (60,2);writeln ('Total Harga');
gotoxy (1,3);writeln ('====================================');
for i:=1 to m do
begin
gotoxy (1,3+i); writeln(i);
gotoxy (5,3+i); writeln(kd_brg[i]);
gotoxy (18,3+i); writeln(nama_brg[i]);
gotoxy (31,3+i); writeln(harga[i]);
gotoxy (40,3+i); writeln(jumlah[i]);
gotoxy (47,3+i); writeln(diskon[i]);
gotoxy (60,3+i); writeln(tharga[i]);
end;
writeln ('========================================');
readln;
end.
oleh zulfan (Stmik Budidarma Medan)