program UAS;
uses crt;
type
siswa=record
nim : string[50];
nama : string[50];
NilaiMhs : array [1..4, 1..5] of integer;
end;
type
kuliah = array[1..20] of siswa;
var
kul : kuliah;
IP : real;
menu, n : integer;
jawab : char;
function BN(bobot : integer): char;
begin
case bobot of
0 : BN := 'E';
1 : BN := 'D';
2 : BN := 'C';
3 : BN := 'B';
4 : BN := 'A';
end;
end;
procedure khs(kul : kuliah);
var
jumsks, jumMk, i, j : integer;
IP : real;
begin
for i := 1 to n do
begin
writeln('Nim : ',kul [i].nim);
writeln('Nama : ',kul [i].nama);
writeln('Mk Sks Nilai Bobot');
jumsks := 0; jumMk := 0;
for j := 1 to n do
begin
writeln (kul[i].NilaiMhs[1,j]:2,' ',kul[i].NilaiMhs[2,j]:2,' ',
BN(kul[i].NilaiMhs[4,j]) :4,' ',kul[i].NilaiMhs[4,j]:5);
jumsks := jumsks + kul[i].NilaiMhs[2,j];
jumMk := jumMk + kul[i].NilaiMhs[2,j] * kul[i].NilaiMhs[4,j];
end;
if jumsks <> 0 then
IP := jumMk / jumsks;
writeln;
writeln('IP = ',IP:0:2);
readln;
end;
end;
function bobot(nilai : integer): integer;
begin
if nilai < 40 then
bobot := 0
else
if (nilai >= 40) and (nilai < 55) then
bobot := 1
else
if (nilai >= 55) and (nilai < 65) then
bobot := 2
else
if (nilai >= 65) and (nilai < 76) then
bobot := 3
else
bobot := 4;
end;
procedure masukdata(var kul : kuliah);
var
i,j : integer;
begin
clrscr;
write('Banyak mahasiswa : '); readln(n);
for i := 1 to n do
begin
write('Nim : '); readln(kul[i].nim);
write('Nama : '); readln(kul[i].nama);
writeln;
for j := 1 to n do
begin
write('Mk_ke : '); readln(kul[i].NilaiMhs[1,j]);
write('Sks : '); readln(kul[i].NilaiMhs[2,j]);
write('Point : '); readln(kul[i].NilaiMhs[3,j]);
writeln('Bobot Nilai : ',bobot(kul[i].NilaiMhs[3,j]));
kul[i].NilaiMhs[4,j] := bobot(kul[i].NilaiMhs[3,j]);
writeln('Nilai : ', BN(bobot(kul[i].NilaiMhs[3,j])));
writeln;
end;
end;
end;
procedure PPH;
var
peng, ph : longint;
pp : longint;
begin
clrscr;
write('Masukkan penghasilan anda Rp. '); readln(peng);
if peng <= 300000 then
begin
writeln;
writeln('Penghasilan Rp. ',peng);
writeln('Pph Rp. -');
end
else
if (peng > 300000) and (peng <=10000000) then
begin
writeln;
pp := round (15/100 * peng);
ph := peng-pp;
writeln('Penghasilan Rp. ',ph);
writeln('Pph Rp. ',pp);
end
else
if peng > 10000000 then
begin
writeln;
pp := round (20/100 * peng);
ph := peng-pp;
writeln('Penghasilan Rp. ',peng);
writeln('Pph Rp. ',ph);
end;
readln;
end;
begin
clrscr;
repeat
writeln;
writeln('***==== Welcome To Programe Project Take Home ====***');
writeln;
writeln('Menu Pilihan Anda :');
writeln;
writeln('1. Menghitung IPK');
writeln('2. Menghitung PPH');
writeln('3. Keluar');
writeln;
write('Masukkan Menu pilihan (1/2/3) : '); readln(menu);
if (menu=1) then
begin
masukdata(kul);
readln;
khs(kul);
end
else
if (menu=2) then
begin
PPH;
end
else
begin
exit;
end;
writeln;
write('Apakah Anda ingin menampilkan lagi? (Y/T) : '); readln(jawab);
until (jawab = 'T');
readln;
end.