Contoh 1
program lat_recor;
{$APPTYPE CONSOLE}
uses
SysUtils;
type mahasiswa=record
nim:integer;
nama,jurusan,alamat:string;
end;
var mhs1,mhs2,mhs3,mhs4,mhs5:mahasiswa;
begin
writeln('----------------------');
writeln('input data mahasiswa 1');
writeln('----------------------');
write('nim mhs1 : ');readln(mhs1.nim);
write('nama mhs1 : ');readln(mhs1.nama);
write('jurusan mhs1 : ');readln(mhs1.jurusan);
write('alamat mhs1 : ');readln(mhs1.alamat);
writeln;
writeln('----------------------');
writeln('input data mahasiswa 2');
writeln('----------------------');
write('nim mhs2 : ');readln(mhs2.nim);
write('nama mhs2 : ');readln(mhs2.nama);
write('jurusan mhs2 : ');readln(mhs2.jurusan);
write('alamat mhs2 : ');readln(mhs2.alamat);
writeln;
writeln('----------------------');
writeln('input data mahasiswa 3');
writeln('----------------------');
write('nim mhs3 : ');readln(mhs3.nim);
write('nama mhs3 : ');readln(mhs3.nama);
write('jurusan mhs3 : ');readln(mhs3.jurusan);
write('alamat mhs3 : ');readln(mhs3.alamat);
writeln;
writeln('----------------------');
writeln('input data mahasiswa 4');
writeln('----------------------');
write('nim mhs4 : ');readln(mhs4.nim);
write('nama mhs4 : ');readln(mhs4.nama);
write('jurusan mhs4 : ');readln(mhs4.jurusan);
write('alamat mhs4 : ');readln(mhs4.alamat);
writeln;
writeln('----------------------');
writeln('input data mahasiswa 5');
writeln('----------------------');
write('nim mhs5 : ');readln(mhs5.nim);
write('nama mhs5 : ');readln(mhs5.nama);
write('jurusan mhs5 : ');readln(mhs5.jurusan);
write('alamat mhs5 : ');readln(mhs5.alamat);
writeln;
writeln;
writeln(' DAFTAR MAHASISWA ');
writeln('=========================================================');
writeln('| nim | nama | jurusan | alamat |');
writeln('=========================================================');
writeln(mhs1.nim:10,mhs1.nama:13,mhs1.jurusan:15,mhs1.alamat:15);
writeln(mhs2.nim:10,mhs2.nama:13,mhs2.jurusan:15,mhs2.alamat:15);
writeln(mhs3.nim:10,mhs3.nama:13,mhs3.jurusan:15,mhs3.alamat:15);
writeln(mhs4.nim:10,mhs4.nama:13,mhs4.jurusan:15,mhs4.alamat:15);
writeln(mhs5.nim:10,mhs5.nama:13,mhs5.jurusan:15,mhs5.alamat:15);
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
Contoh 2
program lat2_recor;
{$APPTYPE CONSOLE}
uses
SysUtils;
type penjualan=record
kode,harga:integer;
barang:string;
end;
var jual1,jual2,jual3:penjualan;
begin
writeln('----------------------');
writeln('input data penjualan 1');
writeln('----------------------');
write('kode jual1 : ');readln(jual1.kode);
write('barang jual1 : ');readln(jual1.barang);
write('harga jual1 : ');readln(jual1.harga);
writeln;
writeln('----------------------');
writeln('input data penjualan 2');
writeln('----------------------');
write('kode jual2 : ');readln(jual2.kode);
write('barang jual2 : ');readln(jual2.barang);
write('harga jual2 : ');readln(jual2.harga);
writeln;
writeln('----------------------');
writeln('input data penjualan 3');
writeln('----------------------');
write('kode jual3 : ');readln(jual3.kode);
write('barang jual3 : ');readln(jual3.barang);
write('harga jual3 : ');readln(jual3.harga);
writeln;
writeln;
writeln(' DAFTAR PENJUALAN ');
writeln(' ============================');
writeln(' | kode | barang | harga |');
writeln(' ============================');
writeln(jual1.kode:10,jual1.barang:10,jual1.harga:10);
writeln(jual2.kode:10,jual2.barang:10,jual2.harga:10);
writeln(jual3.kode:10,jual3.barang:10,jual3.harga:10);
writeln;
writeln('TOTAL HARGA : ',jual1.harga+jual2.harga+jual3.harga);
readln;
{ TODO -oUser -cConsole Main : Insert code here }
end.
0 komentar:
Posting Komentar