Procedure

Referensi Algo 2 (Pascal)
USES CRT;
CONST
     max = 10;
     garis = '----------------------------------------------------------------';
 TYPE
     rec_data = record;
     nip : string[25];
     nama : string[25];
     gol : string[5];
     gapok : real;
     tunj : real;
     gator : real;
     pot : real;
     gaber : real;
 END;
 VAR
     rpeg : rec_data;
     peg : file of rec_data;
     lagi : char;

 PROCEDURE entrydata;
   BEGIN
     ASSIGN (peg,'c:peg.dat');
     REWRITE (peg);
     CLRSCR;
       BEGIN
          CLRSCR;
          WRITE ('nip :');READLN(rpeg.nip);
          IF rpeg.nip=" THEN HALT;
          WRITE ('nama :');READLN(rpeg.nama);
          WRITE ('golongan :');READLN(rpeg.gol);
       END;
   END;
   {Akhir procedure entrydata}

 PROCEDURE prosesdata;
   BEGIN
     IF rpeg.gol = 'I/a' THEN rpeg.gapok :=250000;
     IF rpeg.gol = 'I/b' THEN rpeg.gapok :=300000;
     IF rpeg.gol = 'II/a' THEN rpeg.gapok :=350000;
     IF rpeg.gol = 'II/b' THEN rpeg.gapok :=400000;
     IF rpeg.gol = 'III/a' THEN rpeg.gapok :=450000;
     IF rpeg.gol = 'III/b' THEN rpeg.gapok :=500000;
     rpeg.tunj :=(0.1)*rpeg.gapok;
     rpeg.gator :=rpeg.gapok*rpeg.tunj;
     rpeg.pot :=(0.02)*rpeg.gator;
     rpeg.gaber :=rpeg.gator-rpeg.pot;
   END;
   {Akhir procedure prosesdata}

 PROCEDURE tampildata;
   BEGIN
     CLRSCR;
     GOTOXY (1,1);WRITE (' daftar gaji pegawai ');
     GOTOXY (1,2);WRITE (garis);
     GOTOXY (1,3);WRITE (' nip nama gol gapok tunj
gator pot gaber');
     GOTOXY (1,4);WRITE (garis);
     BEGIN
          GOTOXY (2,5) ;WRITELN (rpeg.nip);
          GOTOXY (9,5) ;WRITELN (rpeg.nama);
          GOTOXY (18,5);WRITELN (rpeg.gol);
          GOTOXY (24,5);WRITE (rpeg.gapok:10:0);
          GOTOXY (33,5);WRITE (rpeg.tunj:10:0);
          GOTOXY (44,5);WRITE (rpeg.gator:10:0);
          GOTOXY (54,5);WRITE (rpeg.pot:10:0);
          GOTOXY (68,5);WRITE (rpeg.gaber:10:0);
     END;
   END;
   {Akhir procedure tampildata}

 BEGIN {Program utama}
     CLRSCR;
     REPEAT
          entrydata;
          prosesdata;
          tampildata;
          WRITELN;
          WRITE (' coba lagi : [Y/T]:');
          REPEAT
             lagi:=UPCASE (READKEY);
          UNTIL lagi IN ['Y','T'];
     UNTIL lagi ='T';
     CLOSE (peg);
 END.

Share this

Leave a Reply

Your email address will not be published.