Berikut Coding Pascal nya:
program DataMahasiswa;
{I.S.: User memasukkan banyaknya data (N) dan record (1:N)}
{F.S.: Menampilkan Daftar Nilai
Mahasiswa dalam tabel}
uses crt;
const
maks_mhs = 50;
type
data_mhs = record
Nama, NIM : string;
Nilai : integer;
Indeks : char;
end;
array_datamhs = array[1..maks_mhs]of data_mhs;
var
Data : array_datamhs;
i, j : integer;
n : integer;
jumA, jumB, jumC, jumD, jumE : integer;
rata_nilai,total_nilai : real;
terrendah, tertinggi : integer;
begin
textcolor(15);
write('Banyaknya Data : ');readln(n);
{validasi banyaknya data}
while(n<1) or (n>50) do
begin
textcolor(red);
writeln('Banyaknya Data Hanya Boleh 1-5,
Ulangi!');
readln;
gotoxy(1,2);clreol;
gotoxy(18,1);clreol;
textcolor(15);readln(n);
end;
{membuat judul tabel & header tabel}
clrscr;
gotoxy(33,5);write('DAFTAR NILAI
MAHASISWA');
gotoxy(33,6);write('----------------------');
gotoxy(15,7);
write('________________________________________________________');
gotoxy(15,8);
write('| NO | NIM
| NAMA MAHASISWA | NILAI | INDEKS |');
gotoxy(15,9);
write('________________________________________________________');
{inisialisasi}
jumA := 0; jumB := 0; jumC := 0; jumD :=
0; jumE := 0;
total_nilai := 0;
{mengolah record mahasiswa (1:n)}
for i := 1 to n do
begin
gotoxy(15,10);write('| |
| |
| |');
{menampilkan nomor urut}
gotoxy(17,10);write(i);
gotoxy(22,10);readln(Data[i].NIM);
while (i <= n) do
begin
gotoxy(34,i +
9);readln(Data[i].Nama);
gotoxy(55,i +
9);readln(Data[i].Nilai);
{Validasi Nilai}
while (Data[i].Nilai < 0)
or(Data[i].Nilai > 100) do
begin
gotoxy(50,i + 10);
write('Nilai Hanya dari
0-100,Ulangi!');readln;
gotoxy(55,i + 9);clreol;
readln(Data[i].Nilai);
end;
{menetukan indeks nilai dan jumlah
per-indeks}
case (Data[i].Nilai) of
80..100 : begin
Data[i].Indeks := 'A';
jumA := jumA + 1;
end;
70..79 : begin
Data[i].Indeks := 'B';
jumB := jumB + 1;
end;
60..69 : begin
Data[i].Indeks := 'C';
jumC := jumC + 1;
end;
50..59 : begin
Data[i].Indeks := 'D';
jumD := jumD + 1;
end;
0..49 : begin
Data[i].Indeks := 'E';
jumE := jumE + 1;
end;
end;
gotoxy(66,i+9);
write(Data[i].Indeks);
total_nilai := total_nilai +
Data[i].Nilai;
i := i + 1;
gotoxy(15,i + 9);write('| |
| | |
|');
gotoxy(17,i + 9);write(i);
gotoxy(22,i + 9);readln(Data[i].NIM);
end;{endfor}
gotoxy(15,i+9);
write('========================================================');
{menghitung rata-rata}
rata_nilai := total_nilai / n;
gotoxy(15,i + 11);write('Nilai
Rata-rata : ',rata_nilai:0:1);
{mencari Nilai Tertinggi Dan Terrendah}
terrendah := 999;
tertinggi := -999;
for j := 1 to n do
begin
if (Data[j].Nilai>= tertinggi)
then
tertinggi := Data[j].Nilai;
if (Data[j].Nilai<terrendah)
then
terrendah := Data[j].Nilai;
end;
gotoxy(15,i + 12);write('Nilai
Tertinggi : ',tertinggi);
gotoxy(15,i + 13);write('Nilai
Terrendah : ',terrendah);
gotoxy(15,i + 14);write('Jumlah Indeks
A : ',jumA,' Mahasiswa');
gotoxy(15,i + 15);write('Jumlah Indeks
B : ',jumB,' Mahasiswa');
gotoxy(15,i + 16);write('Jumlah Indeks
C : ',jumC,' Mahasiswa');
gotoxy(15,i + 17);write('Jumlah Indeks
D : ',jumD,' Mahasiswa');
gotoxy(15,i + 18);write('Jumlah Indeks
E : ',jumE,' Mahasiswa');
gotoxy(15,i + 21);write('TEKAN ENTER
UNTUK KELUAR DARI PROGRAM');
readln;
end;{endwhile}
end.
EmoticonEmoticon