Source Code Program Pascal : Mengurutkan nilai IPK
1 of 5
Downloaded 24 times
More Related Content
Program pascal menghitung ipk
1. Source Code <Pascal>
program latihan;
uses wincrt;
type mhs=record
nama,alamat,ket:string;
nim:longint;
ip:real;
end;
larik_mhs=array[1..20] of mhs;
var
maha,tabel:larik_mhs;
i,n,j:byte;
lagi:char;
pil:1..5;
max,min:real;
procedure isi_data(var x:larik_mhs);
begin
repeat
begin
inc(n);
writeln('Isi data mahasiswa ke ',n);
write('Input NIM => ');readln(x[n].nim);
write('Input Nama => ');readln(x[n].nama);
write('Input Alamat => ');readln(x[n].alamat);
write('Input IP => ');readln(x[n].ip);
writeln;
write('Isi lagi<y/t>? ');readln(lagi);
end
until(lagi<>'y');
end;
procedure cetak(var x:larik_mhs);
begin
writeln('Tabel Data Mahasiswa');
writeln;
writeln('=================================================================');
writeln(' NIM Nama Alamat IP Keterangan');
writeln('=================================================================');
writeln;
for i:=1 to n do with x[i] do
begin
if (ip>3.59) then ket:='Amat Baik' else
if (ip<=3.58) and (ip>=3.50) then ket:='Baik' else
if (ip<=3.49) and (ip>=3.00) then ket:='Cukup' else
if (ip<=2.99) and (ip>=2.50) then ket:='Kurang' else
ket:='Sangat Kurang';
writeln(nim:5,' ',nama:15,' ',alamat:10,' ',ip:6:2,' ',ket:10);
writeln('-----------------------------------------------------------------');
2. end;
end;
procedure maks(var x:larik_mhs);
begin
max:=0;
min:=255;
for i:=1 to n do
begin
for j:=1 to n do
begin
if x[n].ip>max then max:=x[n].ip else
if x[n].ip<min then min:=x[n].ip;
end;
end;
end;
procedure sort_ip(var x:larik_mhs);
var sementara:mhs;
begin
for i:=1 to n do tabel[i]:=x[i];
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if (tabel[i].ip<tabel[j].ip) then
begin
sementara:=tabel[i];
tabel[i]:=tabel[j];
tabel[j]:=sementara;
end;
end;
end;
writeln('Data diurutkan berdasarkan IP');
writeln;
cetak(tabel);
end;
procedure sort_abjad(var x:larik_mhs);
var sementara:mhs;
begin
for i:=1 to n do tabel[i]:=x[i];
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if (tabel[i].nama>tabel[j].nama) then
begin
sementara:=tabel[i];
tabel[i]:=tabel[j];
tabel[j]:=sementara;
end;
3. end;
end;
writeln('Data telah diurutkan berdasarkan abjad');
cetak(tabel);
end;
begin
repeat
begin
clrscr;
writeln(' Tabel Data Mahasiswa');
writeln('1.Isi data mahasiswa');
writeln('2.Cetak data mahasiswa');
writeln('3.Mengurutkan data mahasiswa berdasarkan abjad');
writeln('4.Mengurutkan data mahasiswa berdasarkan IP tertinggi');
writeln('5.Selesai');
writeln;
write('Select (1-5)= ');readln(pil);
case pil of
1:isi_data(maha);
2:begin
cetak(maha);
maks(maha);
writeln('IP Tertinggi = ',max:4:2);
writeln('IP Terendah = ',min:4:2);
end;
3:sort_abjad(maha);
4:sort_ip(maha);
5:writeln('Program Exit');
end;
readln;
end
until(pil=5);
end.
4. Hasil Source Code diatas :
Screenshot:
Input Data
Cetak Data Mahasiswa
Mengurutkan data berdasarkan abjad