Minggu, 01 Mei 2011

Program mencari gaji dengan menggunakan Procedure

Program Mencari_gaji;
Uses crt;
Type
  Pegawai = Record
    NIP  : string[8];
    Nama : string[20];
    GOL  : string[3];
  end;
Var
  rPeg      : Array[1..20] of Pegawai;
  i,j       : byte;
  Gaji,TGaji: longint;
  lg          : char;
Procedure InputPegawai;
  Procedure FormPegawai;
  begin
    clrscr;
    Gotoxy(20,2); write('INPUT DATA GAJI PEGAWAI');
    Gotoxy(10,3); write('___________________________________');
    Gotoxy(10,4); write('NIP           :');
    Gotoxy(10,5); write('Nama          :');
    Gotoxy(10,6); write('GOL [I,II,II] :');
    Gotoxy(10,7); write('___________________________________');
    Gotoxy(10,8); write('Isikan Data Lagi[Y/T] :');
  end;
  begin
    Repeat
      FormPegawai;
      With Rpeg[i] do
      begin
         Gotoxy(27,4); readln(NIP);
         Gotoxy(27,5); readln(Nama);
         Gotoxy(27,6); readln(GOL);
         Gotoxy(33,8); readln(lg);
      end;
      inc(i);
      Until upcase(lg)='T';
  end;
  Procedure TabelPegawai;
  begin
    clrscr;
    Gotoxy(3,3); write('LAPORAN DATA GAJI PEGAWAI');
    Gotoxy(3,4); write('_____________________________________________________');
    Gotoxy(3,5); write('   No  NIP      NAMA               GOL   GAJI RP.');
    Gotoxy(3,6); write('_____________________________________________________');
  end;
  Procedure HitGaji(cGol : string; Var nGaji :longint);
  begin
    if cGol ='I' then nGaji:=750000
    else if cGol ='II' then nGaji:=1000000
    else if cGol ='III' then nGaji:=1500000
    else nGAji:=0;
  end;
  begin
    i:=1;
    InputPegawai;
    TabelPegawai;
    for j:=1 to I-1 do
    begin
      With RPeg[j] do
      begin
      HitGAji(Gol,Gaji);
      Gotoxy(5,6+j); write(j:2,'  ',NIP:8,'  ',NAMA);
      Gotoxy(38,6+j); write(Gol);
      Gotoxy(43,6+j); write(Gaji:8);
      TGaji := TGaji+Gaji;
    end;
  end;
  Gotoxy(3,7+j); write('_____________________________________________________');
  Gotoxy(3,8+j); write('TOTAL GAJI                      RP.',tgaji:10);
  Repeat until keypressed;
End.

Setelah kita buat Programnya, maka tekan tombol F9 untuk mengetahui sukses ngak nya program tersebut. setelah sukses tekan tombol Ctrl+F9 untuk menjalankannya…

Ini tampilan program setelah di Run (Ctrl+F9)

Isikan data [Y/T] tersebut sampai pada T, inilah hasilnya……….