Social Icons

twitterfacebookgoogle pluslinkedinrss feedemail

Sabtu, 30 Maret 2013

Program Pascal Menghitung Nilai IPK semester

Berikut Contoh Program Pascal untuk menghitung nilai IPK dalam satu semester

Source Code:
Program Hitung_IPK;
Uses wincrt;
const MaxMK = 150;
Type
   { Tabel Identitas Mahasiswa }
   TblMK = ^IDMK;
   IDMK  = record
             NamaMK    : string[30];
             SKS       : integer;
             Nilai     : char;
             BT        : byte;
             NextIDMK,
             PrevIDMK  : integer;  { Posisi Record }
           end;

Var
    NIM        : string[15];
    NamaMhs    : string[30];
    DosenPembimbing  : string[30];
    Jurusan    : string[30];
    i, n       : byte;
    DataMK     : array [1..MaxMK] of TblMK;

    JMK,NL,
    IP,JBT,JSKS   :Integer;

procedure InputID;
var ch : char;
begin
   writeln('[1] Identitas Mahasiswa');
   writeln('-----------------------');
   write('NIM        : ');readln(NIM);
   write('Nama       : ');readln(NamaMhs);
   write('Jurusan    : ');readln(Jurusan);
   write('Dosen Pembimbing: ');readln(Dosenpembimbing);
   writeln;
   write('Tekan sembarang tombol untuk melanjutkan...!');
   ch := readkey;
end;

procedure InputMK;
var ch : char;
begin
   clrscr;
   writeln('[2] Nilai Mahasiswa');
   writeln('-----------------------');
   write('Jumlah MK : ');readln(n);

   if (n > MaxMK) then
   begin
      write('Jumlah MK > ',MaxMK);
      halt;
   end
   else
   begin
      for i:=1 to n do
   begin
         new(DataMK[i]);
         writeln;
         writeln('Mata Kuliah (MK) ke-',i);
         writeln('-----------------------');
         write('Nama MK   : ');readln(DataMK[i]^.NamaMK);
         write('Jml SKS   : ');readln(DataMK[i]^.SKS);
         write('Nilai (A/B/C/D/E) : ');readln(DataMK[i]^.Nilai);

         with DataMK[i]^ do
     begin
            Nilai := upcase (Nilai);
            case Nilai of
              'A' :NL:=4;
              'B' :NL:=3;
              'C' :NL:=2;
              'D' :NL:=1;
            else NL:=0
     end;
            BT:=NL*SKS;
            JSKS:=JSKS+SKS;
            JBT:=JBT+BT;
     end;
     end;
   end;
   writeln;
   write('Tekan sembarang tombol untuk melanjutkan...!');
   ch := readkey;
end;

procedure ViewNilai;
var ch : char;
begin
   clrscr;
   writeln('[3] Tampilan Nilai');
   writeln('-----------------------');
   writeln('Hasil Perhitungan Indeks Prestasi (IP)');
   writeln;
   writeln('NIM        : ',NIM);
   writeln('Nama       : ',NamaMhs);
   writeln('Jurusan    : ',Jurusan);
   writeln('Dosen Pembimbing : ',Dosenpembimbing);
   writeln;
   writeln('===================================================');
   writeln(' No   Mata Kuliah            Jml SKS       Nilai   ');
   writeln('===================================================');
   for I:=1 to n do
 begin
     with DataMK[i]^ do
   begin
        Gotoxy (2,I+12);write(I:2);
        Gotoxy (7,I+12);write(NamaMK);
        Gotoxy (33,I+12);write(SKS);
        Gotoxy (46,I+12);write(Nilai);
        writeln;
    end;
 end;
  writeln('---------------------------------------------------');
  writeln('Jumlah Mata Kuliah = ',N);
  writeln('Total SKS          = ',JSKS);
  writeln('Total Nilai        = ',JBT);
  writeln;
  write('IP yang diperoleh  = ',JBT/JSKS:0:3);
  writeln;
  writeln;
  write('<< SELESAI >> Tekan sembarang tombol untuk melanjutkan...!');
  ch := readkey;
end;

Begin  { Program UTAMA }
  clrscr;
  writeln('------------------------------------');
  writeln(' PROGRAM HITUNG IPK                 ');
  writeln(' MENGGUNAKAN METODE POINTER & ARRAY ');
  writeln('------------------------------------');
  writeln(' Developed By: ASEP JAENUDIN        ');
  writeln('          SARIAK-LAYUNG.BLOGSPOT.COM');
  writeln('------------------------------------');
  writeln;writeln;
  InputID;
  InputMK;
  ViewNilai;
End.

Tidak ada komentar: