Tugas Praktikum Pertemuan 1
Program data nilai mahasiswa
Berikut adalah source code dalam membuat program data
mahasiswa menggunakan array dan record:
program
Array_dan_Record;
Uses
crt;
Type
rec_data = record
nama,nim,grade :Array[1..100]Of String;
nilai :Array[1..100]Of Real;
end;
Var i,n
:longint;
pilih
:char;
data
:rec_data;
procedure
input;
begin
clrscr;
writeln('>=======================================================<');
writeln('>Masukkan Jumlah Data : <');
writeln('>=======================================================<');
gotoxy(25,2);readln(n);
for I:=1 to n do
begin
writeln('>=======================================================<');
Writeln('> Data Ke <');
Writeln('>-------------------------------------------------------<');
Writeln('>Nama : <');
Writeln('>NIM : <');
writeln('>Nilai : <');
writeln('>=======================================================<');
gotoxy(32,4+7*(i-1));writeln(i);
gotoxy(18,6+7*(i-1));readln(data.nama[i]);
gotoxy(18,7+7*(i-1));readln(data.nim[i]);
gotoxy(18,8+7*(i-1));readln(data.nilai[i]);
with data do
if (nilai[i]<0 i="" nilai="" or="">100)
then grade[i]:='ERROR'else 0>
if nilai[i]>=80 then
grade[i]:='A'else
if nilai[i]>=75 then
grade[i]:='B+'else
if nilai[i]>=70 then
grade[i]:='B'else
if nilai[i]>=65 then
grade[i]:='C+'else
if nilai[i]>=60 then
grade[i]:='C'else
if nilai[i]>=50 then
grade[i]:='D'else
if nilai[i]<50 grade="" i="" o:p="" then="">50>
writeln;
end;
end;
procedure
output;
begin
clrscr;
writeln('+==============================================+');
writeln('| Laporan Data Mahasiswa |');
Writeln('+-----------+------------------+-------+-------+');
writeln('| NIM
| Nama
| Nilai | Grade |');
Writeln('| | | |
|');
Writeln('+-----------+------------------+-------+-------+');
with data do
For i:=1 To n Do
Begin
gotoxy(1,6+i);writeln('|');
gotoxy(13,6+i);writeln('|');
gotoxy(32,6+i);writeln('|');
gotoxy(40,6+i);writeln('|');
gotoxy(48,6+i);writeln('|');
gotoxy(3,6+i);Writeln(nim[i]);
gotoxy(15,6+i);writeln(nama[i]);
gotoxy(35,6+i);writeln(nilai[i]:2:0);
gotoxy(43,6+i);writeln(grade[i]);
end;
Writeln('+===========+==================+=======+=======+');
readln;
end;
procedure
menu;
begin
repeat
clrscr;
writeln('>======================================<');
writeln('> Menu Utama <');
writeln('>--------------------------------------<');
writeln('>1.Masukkan Data <');
writeln('>2.Lihat Data <');
writeln('>3.Keluar <');
writeln('>--------------------------------------<');
writeln('>Masukkan Pilihan : <');
writeln('>======================================<');
gotoxy(21,8);readln(pilih);
case pilih of
'1':input;
'2':output;
end;
until pilih='3';
end;
begin
menu;
end.
Untuk mengetahui bagaimana proses
kerja pada program ini bisa klik disini.
Terima kasih
telah berkunjung keblog ini.