Rabu, 11 Mei 2011

Pemakaian Procedure(LATIHAN92.pas)

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 ;
PIL,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,III] :');
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(27,8);READLN(LG);
END;
INC(I);
UNTIL UPCASE(LG)='T';
END;


PROCEDURE OUTPUTPEGAWAI;
PROCEDURE TABELPEGAWAI;
BEGIN
CLRSCR;
GOTOXY(3,3);WRITE('LAPOARAN 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
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(44,6+J);WRITE(GOL);
GOTOXY(49,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;

PROCEDURE MENU;
BEGIN
CLRSCR;
GOTOXY(20,2);WRITE('MENU PEGAWAI');
GOTOXY(10,3);WRITE('------------');
GOTOXY(10,4);WRITE('[1].INPUT DATA PEGAWAI');
GOTOXY(10,5);WRITE('[2].OUTPUT DATA PEGAWAI');
GOTOXY(10,6);WRITE('[3].KELUAR PROGRAM');
GOTOXY(10,7);WRITE('------------------');
GOTOXY(10,8);WRITE('PILIHAN:');
END;

BEGIN
I:=1;PIL:='1';
WHILE PIL<>'3' DO
BEGIN
MENU;
PIL:=READKEY;
CASE PIL OF
'1':INPUTPEGAWAI;
'2':OUTPUTPEGAWAI;
END;
END;
END.