Source Program Dari Data Mahasiswa Menggunakan Array of Record (Dalam Bahasa Pascal)
Syarat copas adalah ATM :
A : Amati
T : Tiru
M : Modifikasi dengan versi sendiri
program Data_Mahasiwa;
{I.S : user
memasukkan banyaknya data (N) dan record mahasiswa (1..N)}
{F.S :
menampilkan daftar nilai mahasiswa}
uses crt;
const
Maks_Mhs = 50;
type
Data_Mhs = record
NIM : string[8];
Nama :
string[22];
Nilai : integer;
Indeks : char;
end;
Mahasiswa = array[1..Maks_Mhs] of Data_Mhs;
var
Mhs :
Mahasiswa;
N, i : integer;
IndeksA,IndeksB,IndeksC,IndeksD,IndeksE : integer;
TotalNilai,Tertinggi,Terendah : integer;
Rata_rata : real;
Ketemu : boolean;
Nim1,Nim2,Nim3,Nim4,Nim5,Nim6,Nim7,Nim8,Nim9,Nim10 : integer;
Nim11,Nim12,Nim13,Nim14,Nim15,Nim16,Nim17,Nim18,Nim19,Nim20 : integer;
Nim21,Nim22,Nim23,Nim24,Nim25,Nim26,Nim27,Nim28,Nim29,Nim30 : integer;
Nim31,Nim32,Nim33,Nim34,Nim35,Nim36,Nim37,Nim38,Nim39,Nim40 : integer;
Nim41,Nim42,Nim43,Nim44,Nim45,Nim46,Nim47,Nim48,Nim49,Nim50 : integer;
begin
gotoxy(1,1);
textcolor(15);
write('Masukkan
Banyaknya Data : '); readln(N);
{Validasi Banyaknya Data}
while (N>50)
or (N<1) do
begin
textcolor(red);
writeln('Banyaknya
Data Hanya Boleh 1-50, Ulangi...!');
readln;
gotoxy(1,2);clreol;
gotoxy(27,1);clreol;
textcolor(15);readln(N);
end;
{Membuat Judul Tabel dan Header Tabel}
clrscr;
gotoxy(29,1);write('Daftar Nilai
Mahasiswa');
gotoxy(27,2);write('==========================');
gotoxy(6,3);
write('====================================================================');
{ada 68
karakter '='}
gotoxy(6,4);
write('| No
| NIM |
Nama Mahasiswa | Nilai
| Indeks Nilai |');
gotoxy(6,5);
writeln('====================================================================');
{status nim mula-mula belum dimasukkan}
Nim1:=0;Nim2:=0;Nim3:=0;Nim4:=0;Nim5:=0;Nim6:=0;Nim7:=0;Nim8:=0;Nim9:=0;
Nim10:=0;Nim11:=0;Nim12:=0;Nim13:=0;Nim14:=0;Nim15:=0;Nim16:=0;Nim17:=0;
Nim18:=0;Nim19:=0;Nim20:=0;Nim21:=0;Nim22:=0;Nim23:=0;Nim24:=0;Nim25:=0;
Nim26:=0;Nim27:=0;Nim28:=0;Nim29:=0;Nim30:=0;Nim31:=0;Nim32:=0;Nim33:=0;
Nim34:=0;Nim35:=0;Nim36:=0;Nim37:=0;Nim38:=0;Nim39:=0;Nim40:=0;Nim41:=0;
Nim42:=0;Nim43:=0;Nim44:=0;Nim45:=0;Nim46:=0;Nim47:=0;Nim48:=0;Nim49:=0;
Nim50:=0;
{Inisialisasi}
IndeksA
:= 0;
IndeksB
:= 0;
IndeksC
:= 0;
IndeksD
:= 0;
IndeksE
:= 0;
Tertinggi
:= -999;
Terendah
:= 999;
TotalNilai
:= 0;
{Mengolah Record Mahasiswa (1:N)}
for
i := 1 to
N do
{Menampilkan Nomor urut}
begin
gotoxy(6,i+5);
write('| |
| | | |');
gotoxy(6,i+6);
write('===================================================================='); {ada 68 karakter '='}
gotoxy(8,i+5);
writeln(i);read;
{memasukkan nim, nama, nilai}
gotoxy(13,i+5);
readln(Mhs[i].NIM);
while
(Mhs[i].NIM<>'10113230') and (Mhs[i].NIM<>'10113231') and
(Mhs[i].NIM<>'10113232') and
(Mhs[i].NIM<>'10113233') and
(Mhs[i].NIM<>'10113234') and
(Mhs[i].NIM<>'10113235') and
(Mhs[i].NIM<>'10113236') and
(Mhs[i].NIM<>'10113237') and
(Mhs[i].NIM<>'10113238') and
(Mhs[i].NIM<>'10113239') and
(Mhs[i].NIM<>'10113240') and
(Mhs[i].NIM<>'10113241') and
(Mhs[i].NIM<>'10113242') and
(Mhs[i].NIM<>'10113243') and
(Mhs[i].NIM<>'10113244') and
(Mhs[i].NIM<>'10113245') and
(Mhs[i].NIM<>'10113246') and
(Mhs[i].NIM<>'10113247') and
(Mhs[i].NIM<>'10113248') and
(Mhs[i].NIM<>'10113249') and
(Mhs[i].NIM<>'10113250') and
(Mhs[i].NIM<>'10113251') and
(Mhs[i].NIM<>'10113252') and
(Mhs[i].NIM<>'10113253') and
(Mhs[i].NIM<>'10113254') and
(Mhs[i].NIM<>'10113255') and
(Mhs[i].NIM<>'10113256') and
(Mhs[i].NIM<>'10113257') and
(Mhs[i].NIM<>'10113258') and
(Mhs[i].NIM<>'10113259') and
(Mhs[i].NIM<>'10113260') and
(Mhs[i].NIM<>'10113261') and
(Mhs[i].NIM<>'10113262') and
(Mhs[i].NIM<>'10113263') and
(Mhs[i].NIM<>'10113264') and
(Mhs[i].NIM<>'10113265') and
(Mhs[i].NIM<>'10113266') and
(Mhs[i].NIM<>'10113267') and
(Mhs[i].NIM<>'10113268') and
(Mhs[i].NIM<>'10113269') and
(Mhs[i].NIM<>'10113270') and
(Mhs[i].NIM<>'10113271') and
(Mhs[i].NIM<>'10113272') and
(Mhs[i].NIM<>'10113273') and
(Mhs[i].NIM<>'10113274') and
(Mhs[i].NIM<>'10113275') and
(Mhs[i].NIM<>'10113276') and
(Mhs[i].NIM<>'10113277') and
(Mhs[i].NIM<>'10113278') and
(Mhs[i].NIM<>'10113279') do
begin
gotoxy(6,i+7);textcolor(red);
write('Nim
Salah, Nim Hanya Antara 10113230 - 10113279,
Ulangi!');
readln;
gotoxy(13,i+5);clreol;
gotoxy(6,i+7);clreol;
gotoxy(23,i+5);textcolor(15);
write('|
| | |');
gotoxy(13,i+5);
readln(Mhs[i].NIM);
end;
{untuk menemukan status Nim yang belum ada}
Ketemu
:= false;
{mula-mula belum
ditemukan Nim sama}
while(not Ketemu) do
begin
{menentukan nim}
if(Mhs[i].NIM='10113230')
and (Nim1 =0)
then
begin
Nim1
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if(Mhs[i].NIM='10113231')and (Nim2 = 0)
then
begin
Nim2
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if(Mhs[i].NIM='10113232')and (Nim3 = 0)
then
begin
Nim3
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if(Mhs[i].NIM='10113233')and
(Nim4 = 0)
then
begin
Nim4
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if(Mhs[i].NIM='10113234')and (Nim5 = 0)
then
begin
Mhs[i].Nama := 'Wahyu Sae
Setiadi';
Nim5 := 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if(Mhs[i].NIM='10113235')and (Nim6 = 0)
then
begin
Nim6
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if(Mhs[i].NIM='10113236')
and (Nim7 =0)
then
begin
Nim7
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113237') and (Nim8 = 0)
then
begin
Nim8
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113238') and (Nim9 = 0)
then
begin
Nim9
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if (Mhs[i].NIM='10113239') and (Nim10 = 0)
then
begin
Nim10
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if (Mhs[i].NIM='10113240') and (Nim11 = 0)
then
begin
Nim11
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if
(Mhs[i].NIM='10113241') and (Nim12 =0)
then
begin
Nim12
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if (Mhs[i].NIM='10113242') and (Nim13 = 0)
then
begin
Nim13
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if (Mhs[i].NIM='10113243') and (Nim14 = 0)
then
begin
Nim14
:= 1; {nim sudah dimasukkan}
Ketemu
:= true;
end
else
if (Mhs[i].NIM='10113244') and (Nim15 = 0)
then
begin
Nim15
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113245') and (Nim16 = 0)
then
begin
Mhs[i].Nama :=’Hesron Anjuran N’;
Nim16
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113246')
and (Nim17 =0)
then
begin
Nim17
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113247') and (Nim18 = 0)
then
begin
Nim18
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113248') and (Nim19 = 0)
then
begin
Nim19
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113249') and (Nim20 = 0)
then
begin
Nim20
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113250') and (Nim21 = 0)
then
begin
Nim21
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113251') and (Nim22 =0)
then
begin
Nim22
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113252') and (Nim23 = 0)
then
begin
Nim23
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113253') and (Nim24 = 0)
then
begin
Nim24
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113254') and (Nim25 = 0)
then
begin
Nim25
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113255') and (Nim26 = 0)
then
begin
Nim26
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113256')
and (Nim27 =0)
then
begin
Nim27
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113257') and (Nim28 = 0)
then
begin
Nim28
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113258') and (Nim29 = 0)
then
begin
Nim29
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113259') and (Nim30 = 0)
then
begin
Nim30
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113260') and (Nim31 = 0)
then
begin
Nim31
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if
(Mhs[i].NIM='10113261') and (Nim32 = 0)
then
begin
Nim32
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if
(Mhs[i].NIM='10113262') and (Nim33 =0)
then
begin
Nim33
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113263') and (Nim34 = 0)
then
begin
Nim34
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113264') and (Nim35 = 0)
then
begin
Nim35
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113265') and (Nim36 = 0)
then
begin
Nim36
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113266') and (Nim37 = 0)
then
begin
Nim37
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113267')
and (Nim38 =0)
then
begin
Nim38
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113268') and (Nim39 = 0)
then
begin
Nim39
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113269') and (Nim40 = 0)
then
begin
Nim40
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113270') and (Nim41 = 0)
then
begin
Nim41
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113271') and (Nim42 = 0)
then
begin
Nim42
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if
(Mhs[i].NIM='10113272') and (Nim43 =0)
then
begin
Nim43
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113273') and (Nim44 = 0)
then
begin
Nim44
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113274') and (Nim45 = 0)
then
begin
Nim45
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113275') and (Nim46 = 0)
then
begin
Nim46
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113276') and (Nim47 = 0)
then
begin
Nim47
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113277')
and (Nim48 =0)
then
begin
Nim48
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113278') and (Nim49 = 0)
then
begin
Nim49
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
if (Mhs[i].NIM='10113279')and (Nim50 = 0)
then
begin
Nim50
:= 1; {nim sudah dimasukkan}
Ketemu := true;
end
else
begin
{validasi nim yang dimasukkan tidak boleh sama}
gotoxy(6,i+7);textcolor(red);
writeln('Nim
',Mhs[i].NIM,' sudah ada, ulangi...!');
readln;
gotoxy(13,i+5);clreol;
gotoxy(6,i+7); clreol;
gotoxy(17,i+5);textcolor(15);
write(' | | | |');
gotoxy(13,i+5);textcolor(15);
readln(Mhs[i].NIM);
while
(Mhs[i].NIM<>'10113230') and
(Mhs[i].NIM<>'10113231') and
(Mhs[i].NIM<>'10113232')
and (Mhs[i].NIM<>'10113233') and
(Mhs[i].NIM<>'10113234') and
(Mhs[i].NIM<>'10113235') and
(Mhs[i].NIM<>'10113236') and
(Mhs[i].NIM<>'10113237') and
(Mhs[i].NIM<>'10113238') and
(Mhs[i].NIM<>'10113239') and
(Mhs[i].NIM<>'10113240') and
(Mhs[i].NIM<>'10113241') and
(Mhs[i].NIM<>'10113242') and
(Mhs[i].NIM<>'10113243') and
(Mhs[i].NIM<>'10113244') and
(Mhs[i].NIM<>'10113245') and
(Mhs[i].NIM<>'10113246') and
(Mhs[i].NIM<>'10113247') and
(Mhs[i].NIM<>'10113248') and
(Mhs[i].NIM<>'10113249') and
(Mhs[i].NIM<>'10113250') and
(Mhs[i].NIM<>'10113251') and
(Mhs[i].NIM<>'10113252') and
(Mhs[i].NIM<>'10113253') and
(Mhs[i].NIM<>'10113254') and
(Mhs[i].NIM<>'10113255') and
(Mhs[i].NIM<>'10113256') and
(Mhs[i].NIM<>'10113257') and
(Mhs[i].NIM<>'10113258') and
(Mhs[i].NIM<>'10113259') and
(Mhs[i].NIM<>'10113260') and
(Mhs[i].NIM<>'10113261') and
(Mhs[i].NIM<>'10113262') and
(Mhs[i].NIM<>'10113263') and
(Mhs[i].NIM<>'10113264') and
(Mhs[i].NIM<>'10113265') and
(Mhs[i].NIM<>'10113266') and
(Mhs[i].NIM<>'10113267') and
(Mhs[i].NIM<>'10113268') and
(Mhs[i].NIM<>'10113269') and
(Mhs[i].NIM<>'10113270') and
(Mhs[i].NIM<>'10113271') and
(Mhs[i].NIM<>'10113272') and
(Mhs[i].NIM<>'10113273') and
(Mhs[i].NIM<>'10113274') and
(Mhs[i].NIM<>'10113275') and
(Mhs[i].NIM<>'10113276') and
(Mhs[i].NIM<>'10113277') and
(Mhs[i].NIM<>'10113278') and
(Mhs[i].NIM<>'10113279') do
begin
gotoxy(6,i+7);textcolor(red);
write('Nim
Salah, Nim Hanya Antara 10113230 - 10113279,
Ulangi!');
readln;
gotoxy(13,i+5);clreol;
gotoxy(6,i+7);clreol;
gotoxy(23,i+5);textcolor(15);
write('| | | |');
gotoxy(13,i+5);
readln(Mhs[i].NIM);
end;
end;
end;
gotoxy(25,i+5);
write(Mhs[i].Nama); readln(Mhs[i].Nama);
gotoxy(52,i+5);
readln(Mhs[i].Nilai);
{validasi nilai}
while
(Mhs[i].Nilai > 100) or (Mhs[i].Nilai < 0) do
begin
gotoxy(23,i+7);textcolor(red);
write('Nilai
Hanya Antara 0-100, ulangi...!');
readln;
gotoxy(52,i+5);clreol;
gotoxy(23,i+7);clreol;
gotoxy(58,i+5);textcolor(15);
write('| |');
gotoxy(52,i+5);
readln(Mhs[i].Nilai);
end;
{menentukan indeks nilai dan menghitung jumlah
per-indeks}
case
(Mhs[i].Nilai) of
80..100 :begin
Mhs[i].Indeks := 'A';
IndeksA := IndeksA + 1;
end;
70..79 :begin
Mhs[i].Indeks := 'B';
IndeksB := IndeksB + 1;
end;
60..69 :begin
Mhs[i].Indeks := 'C';
IndeksC := IndeksC + 1;
end;
50..59 :begin
Mhs[i].Indeks := 'D';
IndeksD := IndeksD + 1;
end;
0..49 :begin
Mhs[i].Indeks := 'E';
IndeksE := IndeksE + 1;
end;
end; {endcase}
{menentukan nilai tertinggi}
if
(Mhs[i].Nilai > Tertinggi)
then
Tertinggi := Mhs[i].Nilai
else
{Menentukan Nilai Terendah}
if
(Mhs[i].Nilai < Terendah)
then
Terendah := Mhs[i].Nilai;
{Menghitung Total Nilai}
TotalNilai := TotalNilai + Mhs[i].Nilai;
{Menampilkan Indeks Nilai}
gotoxy(65,i+5);
write(Mhs[i].Indeks);
readln;
end;
{Menghitung Rata-Rata Nilai}
Rata_rata := TotalNilai / N;
{Menampilkan Rata-Rata Nilai}
gotoxy(6,i+7);
writeln('Rata -
Rata Nilai : ',Rata_rata:5:2); readln;
{Menampilkan Nilai Tertinggi}
gotoxy(6,i+8);
writeln('Nilai Tertinggi : ',Tertinggi); readln;
{Menampilkan Nilai Terendah}
gotoxy(6,i+9);
writeln('Nilai
Terendah : ',Terendah); readln;
{Menampilkan Jumlah Mahasiswa Per-Indeks}
gotoxy(6,i+10);
writeln('Jumlah
Indeks A : ',IndeksA,' Mahasiswa'); readln;
gotoxy(6,i+11);
writeln('Jumlah
Indeks B : ',IndeksB,' Mahasiswa'); readln;
gotoxy(6,i+12);
writeln('Jumlah
Indeks C : ',IndeksC,' Mahasiswa'); readln;
gotoxy(6,i+13);
writeln('Jumlah
Indeks D : ',IndeksD,' Mahasiswa'); readln;
gotoxy(6,i+14);
writeln('Jumlah
Indeks E : ',IndeksE,' Mahasiswa'); readln;
gotoxy(6,i+16);
textcolor(red);
write('Tekan
sembarang untuk menutup...'); readkey;
end.
Jangan lupa tinggalkan komentar dan kasih +1 ...., Terimakasih