0% found this document useful (0 votes)
31 views5 pages

Source Code

The document contains the source code of a Pascal program that: 1) Defines data types and procedures to input and output transaction data including code, name, and price. 2) Includes main procedures to calculate the average price, most expensive item, least expensive item, and number of prices that are multiples of 3000. 3) The main program prompts the user for the number of transactions, inputs the data, then calls the output and calculation procedures to display the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Source Code

The document contains the source code of a Pascal program that: 1) Defines data types and procedures to input and output transaction data including code, name, and price. 2) Includes main procedures to calculate the average price, most expensive item, least expensive item, and number of prices that are multiples of 3000. 3) The main program prompts the user for the number of transactions, inputs the data, then calls the output and calculation procedures to display the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Source Code
program coba;
uses crt;
const
max = 10;
type
barang = record
kd:byte;
nama:string;
harga:longint;
end;
data=array[0..max] of barang;
var
input:data;
i, n:integer;
a:string;
b:longint;
{prosedur masukan}
procedure masukan(w:byte; x:string; y:longint);
begin
input[i].kd:=w;
input[i].nama:=x;
input[i].harga:=y;
end;
{prosedur keluaran}
procedure keluaran(var t:data);
begin
writeln('Kode : ',t[i].kd);
writeln('Nama : ',t[i].nama);
writeln('Harga : ',t[i].harga);
end;
{prosedur awal}
procedure awal;
begin
input[0].kd:=0;
end;
{prosedur rata}
procedure rerata(t:data);
var
total:longint;
rata:real;
begin
for i:= 1 to n do
total:= total + t[i].harga;
rata:=total / n;
writeln('Rata-rata harga transaksi adalah ',rata:0:0);
end;
{prosedur maxharga}
procedure maxharga(t:data);
var
indeks:byte;
begin
indeks:=1;
for i:= 2 to n do
begin
if t[indeks].harga < t[i].harga then
indeks:=i;
end;
writeln('Harga Termahal adalah ',t[indeks].nama,
' dengan harga ',t[indeks].harga);

end;
{prosedur minharga}
procedure minharga(t:data);
var
indeks:byte;
begin
indeks:=1;
for i:= 2 to n do
begin
if t[indeks].harga > t[i].harga then
indeks:=i;
end;
writeln('Harga Termurah adalah ',t[indeks].nama,
' dengan harga ',t[indeks].harga);
end;
{kelipatan 3000}
procedure kelipatan3000(t:data);
var
kelipatan, jlm:byte;
begin
jlm:=0;
for i:= 1 to n do
begin
if t[i].harga mod 3000 = 0 then
jlm := jlm + 1;
end;
writeln('Terdapat ',jlm,' harga dengan kelipatan 3000');
if jlm > 0 then
write('yaitu : ');
for i:= 1 to n do
begin
if t[i].harga mod 3000 = 0 then
begin
kelipatan:=i;
write(t[kelipatan].harga,' ');
end;
end;
end;
{main program}
begin
clrscr;
awal;
write('masukan jumlah data transaksi : '); readln(n);
for i:= 1 to n do
begin
writeln('Data Ke-',i);
write('Nama : '); readln(a);
write('Harga : '); readln(b);
masukan(i,a,b);
end;
writeln;
writeln;
writeln('Output');
writeln('-------------');
for i:= n downto 1 do
keluaran(input);
writeln('--------------');
rerata(input);
maxharga(input);
minharga(input);

kelipatan3000(input);
readln;
end.

2. Screenshot

Input

output

You might also like