Tugas Prokom ( Mesin Mencari IPK )

Maaf bu terlambat ngirimnya

program Ipk;
uses crt;

type
mahasiswa = record
nama : string[15]; {nama mahasiswa}
nim : string[9]; {nim mahasiswa}
alamat : string[20]; {alamat mahasiswa}
ipk : real; {ipk mahasiswa}
end;
tabel=array[1..60] of mahasiswa; {tabel record}

var
n : integer;
tabmhs: tabel;
pil : char;



{-------------------------Procedure Menu----------------------}

procedure menu;
begin
repeat
clrscr;
gotoxy(5,5); writeln('Program Indeks_Prestasi_Kumulatif');
gotoxy(5,6); writeln('---------------------------------');
gotoxy(8,7); writeln('1.Input Data Mahasiswa');
gotoxy(8,8); writeln('2.Sorting Data Mahasiswa');
gotoxy(8,9); writeln('3.Search Data Mahasiswa');
gotoxy(8,10); writeln('4.Keluar/Exit');
delay(3000);
until keypressed;
end;

{-------------------------Procedure Sorting--------------------}

procedure sorting(var a:tabel);
var
i,j : integer;
temp : real;
temp1,temp2,temp3 : string;


begin
begin
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if ( a[i].ipk ) < (a[j].ipk) then begin temp:=a[i].ipk; temp1:=a[i].nim; temp2:=a[i].nama; temp3:=a[i].alamat; a[i].ipk:=a[j].ipk; a[i].nim:=a[j].nim; a[i].nama:=a[j].nama; a[i].alamat:=a[j].alamat; a[j].ipk:=temp; a[j].nim:=temp1; a[j].nama:=temp2; a[j].alamat:=temp3; end; writeln; end; end; end; gotoxy(5,5); writeln('NIM Nama Alamat IPK '); gotoxy(5,6); writeln('----------------------------------------------------------'); for i:=i to n do begin gotoxy(5,6+i); write(a[i].nim); gotoxy(18,6+i); write(a[i].nama); gotoxy(37,6+i); write(a[i].alamat); gotoxy(60,6+i); write(a[i].ipk:0:2); end; readln; end; {-------------------------Procedure Searching---------------------------------------} procedure search(var a:tabel); var x : string; i : integer; begin begin gotoxy(5,5); write('Ketikkan NIM anda = '); readln(x); i:=1; while (i x ) do
begin
i:=i+1;
end;
if a[i].nim=x then
begin
clrscr;
gotoxy(5,5); writeln('NIM : ',a[i].nim);
gotoxy(5,6); writeln('Nama : ',a[i].nama);
gotoxy(5,7); writeln('alamat : ',a[i].alamat);
gotoxy(5,8); writeln('IPK : ',a[i].ipk:0:2);
readln;
end
else
begin
clrscr;
gotoxy(5,5); write('Data Tidak Ada');
end;
end;
readln;
end;

{-------------------------Procedure Input---------------------------------------}
procedure input(var a:tabel);
var
i : integer;
begin
clrscr;
repeat
clrscr;
gotoxy(5,5);write('Masukkan Banyak data ( min:2 ; max:60 ) : ');
readln(n);
until n<61;
for i:=1 to n do
begin
clrscr;
repeat
clrscr;
gotoxy(5,5); writeln('Data ke : ',i);
gotoxy(5,6); write('NIM : '); readln(a[i].nim);
gotoxy(5,7); write('Nama : '); readln(a[i].nama);
gotoxy(5,8); write('Alamat : '); readln(a[i].alamat);
gotoxy(5,9); write('IPK : '); readln(a[i].ipk);
until (a[i].ipk<=4);
end;
end;

{-------------------------Program Utama-----------------------------------------}
begin
repeat
clrscr;
menu;
pil:=readkey;
case pil of
'1':begin
clrscr;
input(tabmhs);
clrscr;
end;
'2': begin
clrscr;
sorting(tabmhs);
clrscr;
end;
'3': begin
clrscr;
search(tabmhs);
clrscr;
end;
end;
until pil='4';
end.