Friday, July 6, 2012

Code KHS Mahasiswa dengan PASCAL

Code KHS Mahasiswa dengan Pascal

source kode untuk membuat KHS Mahasiswa dengan menggunakan Record dengan Pemrograman Pascal :

program record_data_mahasiswa;
//uses wincrt;
const nMaks = 100;
Mn = 10;
type
matakuliah = record
kodemk : string[8];
namamk : string[20];
sks : integer;
nilai  : string[2];
sksxnilai : real;
end;
mahasiswa = record
NIM : string[15];
nama : string[20];
skstotal : integer;
nilaitotal: real;
ip : real;
nextsks : string[8];
mk : array[1..Mn] of matakuliah;
end;
var
TabMhs : array[1..nMaks] of mahasiswa;
I, J, M, N : integer;
nilaiN : real;
nilaiH : string[2];
tambah : char;
procedure ambilsks;
begin
if TabMhs[I].ip >= 3.00 then TabMhs[I].nextsks := '22 - 24'
else if (TabMhs[I].ip <= 2.99) and (TabMhs[I].ip >= 2.50) then TabMhs[I].nextsks := '22 - 24'
else if (TabMhs[I].ip <= 2.49) and (TabMhs[I].ip >= 2.00) then TabMhs[I].nextsks := '20 - 22'
else if (TabMhs[I].ip <= 1.99) and (TabMhs[I].ip >= 1.50) then TabMhs[I].nextsks := '18 - 20'
else if TabMhs[I].ip < 1.50 then TabMhs[I].nextsks := '16 - 18';
end;
procedure konversinilai;
begin
nilaiH := TabMhs[I].mk[J].nilai;
if (NilaiH = 'A')       or (nilaiH = 'a'then nilaiN := 4
else if (nilaiH = 'B+') or (nilaiH = 'b+') then nilaiN := 3.5
else if (nilaiH = 'B'or (nilaiH = 'b'then nilaiN := 3
else if (nilaiH = 'C+') or (nilaiH = 'c+') then nilaiN := 2.5
else if (nilaiH = 'C'or (nilaiH = 'c'then nilaiN := 2
else if (nilaiH = 'D+') or (nilaiH = 'd+') then nilaiN := 1.5
else if (nilaiH = 'D'or (nilaiH = 'd'then nilaiN := 1
else nilaiN := 0;
end;
procedure tampildata;
begin
for I:= 1 to N do
begin
writeln ('                        Kartu Hasil Studi                        ');
writeln ('                    Jurusan Teknik Informatika                   ');
writeln ('           Fakultas ILMU KOMPUTER UNIKA ST.THOMAS SUMUT          ');
writeln ('                     Semester  20../20..                         ');
writeln('=================================================================');
writeln('Nama Mahasiswa : ',TabMhs[I].nama);
writeln('NPM Mahasiswa : ',TabMhs[I].NIM);
writeln('---------------------------------------------------------------');
writeln(' No    Kode MK    Nama Mata Kuliah    SKS   Nilai   SKS x Nilai');
writeln('---------------------------------------------------------------');
for J := 1 to M do
begin
konversinilai;
TabMhs[I].mk[J].sksxnilai := nilaiN * TabMhs[I].mk[J].sks;
writeln(J:2,TabMhs[I].mk[J].kodemk:13,TabMhs[I].mk[J].namamk:20,TabMhs[I].mk[J].sks:5,TabMhs[I].mk[J].nilai:7,
TabMhs[I].mk[J].sksxnilai:13:1);
TabMhs[I].skstotal := TabMhs[I].skstotal + TabMhs[I].mk[J].sks;
TabMhs[I].nilaitotal := TabMhs[I].nilaitotal + TabMhs[I].mk[J].sksxnilai;
end;
writeln('---------------------------------------------------------------');
writeln('                TOTA L           ',TabMhs[I].skstotal:7,TabMhs[I].nilaitotal:20:1);
writeln('---------------------------------------------------------------');
TabMhs[I].ip := TabMhs[I].nilaitotal / TabMhs[I].skstotal;
writeln('IP Semester = ',TabMhs[I].nilaitotal:0:1,'/',TabMhs[I].skstotal,' = ',TabMhs[I].ip:0:2);
ambilsks;
writeln('SKS yang dapat diambil semester berikutnya = ',TabMhs[I].nextsks);
writeln;
end;
end;
procedure bacadata;
begin
for I := 1 to N do
begin
write('NRP Mahasiswa ke - ',I,' = ');readln(TabMhs[I].NIM);
write('Nama Mahasiswa ke - ',I,' = ');readln(TabMhs[I].nama);
write('Jumlah Mata Kuliah = ');readln(M);
writeln('--------------------------------------------------');
for J := 1 to M do
begin
write('Kode Matakuliah ke - ',J,' = ');readln(TabMhs[I].mk[J].kodemk);
write('Nama Matakuliah = ');readln(TabMhs[I].mk[J].namamk);
write('SKS Matakuliah = ');readln(TabMhs[I].mk[J].sks);
write('nilai Matakuliah = ');readln(TabMhs[I].mk[J].nilai);
writeln('--------------------------------------------------');
end;
end;
end;
begin
write('Masukkan Jumlah Data Mahasiswa = ');readln(N);
Repeat
//clrscr;
bacadata;
//clrscr;
tampildata;
write ('Anda Ingin Memasukkan Data Mahasiswa Lagi? [Y/N] : ');readln(tambah);
tambah := Upcase(tambah);
until (tambah <> 'Y');
//Donewincrt;
end.

0 comments:

Post a Comment

KOMENTAR