Program Mahasiswa;
uses crt;
label 1;
type
DMHS = record
Nama : String;
NPM : String;
Kelas :string;
end;
var
List : array [1..10] of DMHS;
Kelas : array [1..10] of string[5];
NPM : array [1..10] of string[8];
Nama : array [1..10] of string[20];
i,h,j,n,pil,m,s,q : integer;
NPM1,z : String;
temp : DMHS;
procedure insert;
begin
clrscr;
write('INGIN INPUT BERAPA DATA : ');
readln(s);
for q:=1 to s do
begin
inc(i);
inc(n);
clrscr;
gotoxy(30,4); write('Data Mahasiswa ke- ',q:2);
gotoxy(10,7); write('NPM Mahasiswa : '); readln(LIST[q].NPM);
gotoxy(10,8); write('Nama Mahasiswa : '); readln(LIST[q].Nama);
gotoxy(10,9); write('Kelas Mahasiswa : '); readln(LIST[q].KELAS);
end;
end;
procedure cari(z : String);
var
k : integer;
ketemu : boolean;
begin
k := 1;
ketemu := false;
while (not ketemu) and (k <= n) do
if List[k].NPM = z then
ketemu := true
else
k := k + 1;
if ketemu then
begin
gotoxy(21,15); write('Mahasiswa Dengan NPM ',z,' : Ditemukan');
gotoxy(18,17); writeln('|===========|====================|=========|');
gotoxy(18,18); writeln('| NPM | NAMA | KELAS |');
gotoxy(18,19); writeln('|____________|_______________________|__________|');
gotoxy(18,20); writeln('| | | |');
gotoxy(18,21); writeln('| | | |');
gotoxy(20,21); writeln(List[k].NPM);
gotoxy(33,21); writeln(List[k].Nama);
gotoxy(55,21); writeln(List[k].KELAS);
gotoxy(18,22); writeln('|___________|____________________|_________|');
end
else
begin
gotoxy(20,15); write('Mahasiswa Dengan NPM ',z,' : Tidak Ditemukan');
end;
end;
procedure update(p : String);
var
x, y, z : String;
q, o : integer;
ketemu : boolean;
begin
q := 1;
if (NPM1 = '0') or (NPM1 = '') then
begin
gotoxy(15,20); write('Masukkan NPM yang Benar');
end
else
begin
ketemu := false;
while (not ketemu) and (q <= n) do
if List[q].NPM = p then
ketemu := true
else
q := q + 1;
if ketemu then
begin
gotoxy(5,21); write('Data Yang Akan di Update : ');
gotoxy(5,20); write('1. NPM 2. Nama 3. KELAS');
gotoxy(33,21); readln(pil);
case pil of
1 : begin
gotoxy(5,23); write('Masukkan NPM yang Baru : ');
readln(x);
List[q].NPM := x;
end;
2 : begin
gotoxy(5,23); write('Masukkan Nama yang Baru : ');
readln(y);
List[q].Nama := y;
end;
3 : begin
gotoxy(5,23); write('Masukkan KELAS yang Baru : ');
readln(z);
List[q].KELAS := z;
end;
end;
end
else
begin
gotoxy(5,22); write('NPM ',p,' Tidak Terdapat Dalam Daftar');
end;
end;
end;
procedure cetak;
begin
if m = 2 then
begin
gotoxy(37,2); write('Tabel Nilai Mahasiswa Setelah Diurutkan');
end
else if m = 0 then
begin
gotoxy(47,2); write('Tabel Nilai Mahasiswa');
end;
gotoxy(35,4); writeln ('|===========|====================|=========|');
gotoxy(35,5); writeln ('| NPM | NAMA | KELAS |');
gotoxy(35,6); writeln ('|____________|_______________________|__________|');
gotoxy(35,7); writeln ('| | | |');
gotoxy(35,8+n); writeln('|___________|______________________|____________|');
for j := 1 to n do
begin
gotoxy(35,7+j); writeln('| | | |');
gotoxy(37,7+j); writeln(List[j].NPM);
gotoxy(50,7+j); writeln(List[j].Nama);
gotoxy(72,7+j); writeln(List[j].KELAS);
end;
end;
begin
i := 0;
n := 0;
repeat
1 : clrscr;
m := 0;
clrscr;
gotoxy(3,2); writeln ('|===============|');
gotoxy(3,3); writeln ('| Menu |');
gotoxy(3,4); writeln ('| |');
gotoxy(3,5); writeln ('|===============|');
gotoxy(3,6); writeln ('| 1. Insert |');
gotoxy(3,7); writeln ('| 2. Sorting |');
gotoxy(3,8); writeln ('| 3. Update |');
gotoxy(3,9); writeln ('| 4. Exit |');
gotoxy(3,10); writeln('| |');
gotoxy(3,11); writeln('| |');
gotoxy(3,12); writeln('|===============|');
gotoxy(3,13); writeln('| Pilihan : |');
gotoxy(3,14); writeln('|_______________|');
cetak;
gotoxy(16,13); readln (pil);
case pil of
1 : begin
m := 0;
insert;
end;
2 : begin
repeat
clrscr;
gotoxy(3,2); writeln ('|===============|');
gotoxy(3,3); writeln ('| Menu |');
gotoxy(3,4); writeln ('| |');
gotoxy(3,5); writeln ('|===============|');
gotoxy(3,6); writeln ('| 1. NPM |');
gotoxy(3,7); writeln ('| 2. Nama |');
gotoxy(3,8); writeln ('| 3. KELAS |');
gotoxy(3,9); writeln ('| 4. Menu |');
gotoxy(3,10); writeln('| 5. Exit |');
gotoxy(3,11); writeln('| |');
gotoxy(3,12); writeln('|===============|');
gotoxy(3,17); writeln('| Pilihan: |');
gotoxy(3,14); writeln('|_______________|');
cetak;
gotoxy(16,13); readln(pil);
m := 2;
case pil of
1 : begin
for h := 1 to n-1 do
for j := 1 to n-1 do
if List[j].NPM > List[j+1].NPM then
begin
temp := List[j];
List[j] := List[j+1];
List[j+1] := temp;
end;
end;
2 : begin
for h := 1 to n-1 do
for j := 1 to n-1 do
if List[j].Nama > List[j+1].Nama then
begin
temp := List[j];
List[j] := List[j+1];
List[j+1] := temp;
end;
end;
3 : begin
for h := 1 to n-1 do
for j := 1 to n-1 do
if List[j].KELAS > List[j+1].KELAS then
begin
temp := List[j];
List[j] := List[j+1];
List[j+1] := temp;
end;
end;
4 : begin
goto 1;
end;
end;
cetak;
until
pil >= 5;
end;
3 : begin
gotoxy(5,18); write('NPM Mahasiswa Yang Akan di Update : ');
readln(NPM1);
update(NPM1);
end;
end;
until pil >= 4;
end.
Tidak ada komentar:
Posting Komentar