uses wincrt;
const max=100;
type mhs=record
nim:string[10];
nama: string[30];
IPK:real;
end;
kelas=array[1..max] of mhs;
var algo :kelas;
i,n,j,
hapus :integer;
pil,jwb:char;
maks,min,rata,jml :real;
temp :mhs;
begin
n:=0;
repeat
clrscr;
writeln('**************************');
writeln('*******MENU PILIHAN*******');
writeln('**************************');
writeln;
writeln('1. Tambah data');
writeln('2. Hapus data ');
writeln('3. Tampil ');
writeln('4. Statistik ');
writeln('5. Pengurutan ');
writeln('0. Selesai ');writeln;
write('Pilihan Anda : '); readln(pil); writeln;
case pil of
'1':
begin
n:=n+1;
writeln('SILAHKAN ANDA ISI DATA MAHASISWA');
write('NIM Mahasiswa : '); readln(algo[n].NIM);
write('Nama Mahasiswa : '); readln(algo[n].nama);
write('IPK : '); readln(algo[n].IPK); end;
'2': begin
if n=0 then
begin
writeln('Silahkan anda memasukkan data');
readln;
end
else
begin
write('Nomor Data ke: '); readln(hapus);
writeln;
writeln('Data yang akan dihapus!!');
writeln('NIM :',algo[hapus].NIM);
writeln('Nama :',algo[hapus].Nama);
writeln('IPK :',algo[hapus].IPK:5:2);
writeln('Hapus???[Y/T]'); readln(jwb);
if upcase(jwb)='Y' then
begin
for i:=hapus to n-1 do
begin
algo[i]:=algo[i+1];
n:=n-1;
end;
end;
end;
end;
'3': begin
writeln('DATA MAHASISWA');
writeln('-----------------');
writeln('NIM ', ' :2' ,'NAMA '', ' :2, 'IPK');
writeln('-------------------');
for i:=1 to n do
begin
with algo[i] do
begin
writeln(NIM:8, ' ':2, NAMA:25,' ':2, IPK:5:2);
end;
end;
readln;
end;
'4': begin
maks:= algo[1].ipk;
min := algo[1].ipk;
Jml := 0;
for i := 1 to n do
begin
with algo[i] do
begin
if ipk > maks then maks := ipk;
if ipk < min then min := ipk;
jml:=jml+ipk;
end;
end;
rata:=jml/n;
writeln;
writeln('DATA STATISTIK IPK MAHASISWA');
writeln;
writeln('-------------');
writeln('IPK Tertinggi : ',maks:5:2);
writeln('IPK Terendah : ',min:5:2);
writeln('Rata-Rata IPK : ',rata:5:2);
writeln('-------------');
writeln;
readln;
end;
'5': begin
writeln('Data Sebelum Diurutkan: ');
for i:=1 to n do
begin
writeln('IPK mahasiswa ke-',i,' adalah: ',algo[i].IPK:5:2);
end;
writeln;
for i:=1 to n-1 do
begin
for j:=n downto i+1 do
begin
if algo[j].IPK < algo[j-1].IPK then
begin
temp := algo[j];
algo[j] := algo[j-1];
algo[j-1]:= temp;
end;end;end;
writeln;
writeln('Data Setelah Diurutkan : ');
writeln('IPK dari kecil ke besar!');
writeln;
for i:=1 to n do
begin
writeln(algo[i].IPK:5:2);
end;
readln;
end;
'0': writeln('Program selesai, Silahkan kembali ke MENU!');
else
writeln;
writeln('Pilih sesuai MENU yang tersedia!'); readln;
end;
until pil='0';
end.
Tidak ada komentar:
Posting Komentar