Nama : Fince Tinus Waruwu
NPM : 1002040
Kelas : MI-P1001
Soal No 3 Type Karyawan = Record
Kode : String[5];
Jabatan : String [15];
Status : String [10];
end;
Var
fkar : file of karyawan;
rkar : karyawan;
lg : Char ;
i,j,pil : Integer;
Gaji : Longint;
Tunjangan : Real;
Tkeluarga : Real;
Total : Real;
procedure openkaryawan;
Begin
Assign (fkar,'c:\karyawan.dat');
{$I-} Reset (fkar);
{$I+} if IOresult <>0 then Rewrite (fkar);
End;
Procedure Menu;
begin
clrscr;
clrscr;
gotoxy (10,5);write ('MENU UTAMA');
gotoxy (10,6);write ('-----------------------------');
gotoxy (10,7);write ('[1].Input Laporan Gaji Karyawan');
gotoxy (10,8);write ('[2].Output karyawan');
gotoxy (10,9);write ('[3].Keluar karyawan');
gotoxy (10,10);write ('------------------------------');
gotoxy (10,11);write ('pilihan:');readln (Pil);
end;
Procedure Inputkaryawan;
begin
clrscr;
openkaryawan;
repeat
gotoxy (30,5);write ('input Karyawan');
gotoxy (30,6);write ('-----------------');
gotoxy (30,7);write ('Kode');readln (rkar.kode);
gotoxy (30,8);write ('Status');readln (rkar.Status);
gotoxy (30,9);write ('------------------------------');
gotoxy (30,10);write ('Input Lagi [Y/T]:');Readln (lg);
Seek (fkar, filesize (fkar));
write (fkar,rkar);clrscr;
Until Upcase (lg)=('T');
end;
procedure outputkaryawan;
Begin
clrscr;
i:=1 ; openkaryawan;
gotoxy (3,1);write ('Laporan Gaji Karyawan');
gotoxy (3,2);write ('--------------------------------------');
gotoxy (3,3);write ('No Kode Jabatan Tunjangan ');
gotoxy (3,4);write ('--------------------------------------');
Seek (fkar,0);
while not Eof(fkar) do
Begin
Seek (fkar,i-1); read (fkar,rkar);
if rkar.Kode='K001' then
begin
rkar.Jabatan:='Supervriser'; Gaji:= 3000000
end
Else if rkar.Kode='K002' then
begin
rkar.Jabatan:='Sekretaris'; Gaji:= 2500000
end
Else if rkar.Kode='K003' then
begin
rkar.Jabatan:='Bendahara'; Gaji:= 2000000
end
Else if rkar.Kode='K004' then
begin
rkar.Jabatan:='Sales'; Gaji:= 1500000;
gotoxy (3,4+i);write(i:2,' ',rkar.kode,' ',rkar.Jabatan);
gotoxy (20,4+i);write(Gaji:8);
if Gaji= 3000000 then Tunjangan:= 0.35 * 3000000
else if Gaji= 2500000 then Tunjangan:= 0.20 * 2500000
else if Gaji= 2000000 then Tunjangan:= 0.10 * 2000000
else Tunjangan:= 0.5 * 1500000;
gotoxy (30,4+i);write(Tunjangan:9);
if rkar.Status='Menikah' Then
begin
TKeluarga:= 0.15 * Gaji ;
end
else if rkar.Status='Belum Menikah' then
begin
Tkeluarga:=0;
Total:= Gaji + Tunjangan + Tkeluarga;
gotoxy (40,4+i);write (Total:10:0);
inc (i);
end;
READLN;
end;
begin
pil:=0;
while pil <>3 do
begin
menu;
case pil of
1 : Inputkaryawan;
2 : outputkaryawan;
end;
close (fkar);
end ;
end.
Soal No 4
uses wincrt;
type dokter=record
kode :string[3];
nama :string[20];
specialis :string[20];
end;
var
fdok :file of dokter;
rdok :dokter;
i :byte;
xkd :string[3];
lg :char;
ketemu :Boolean;
procedure opendokter;
begin
clrscr;
assign(fdok,'c:\dokterr.dat');
{$I-} reset (fdok);
{$I+} if ioresult<>0 then rewrite(fdok);
end;
begin
clrscr;
opendokter;
repeat
i:=1;
ketemu:=false;
gotoxy(40,3);write('kode:');readln(xkd);
seek (fdok,0);
while not eof(fdok) do
begin
seek (fdok,i-1);read(fdok,rdok);
if rdok.kode=xkd then
begin
gotoxy(40,4);write('nama:',rdok.nama);
gotoxy(40,5);write('specialis:',rdok.specialis);
ketemu:=true;
end;
inc(i);
end;
rdok.kode:=xkd;
if not ketemu then
begin
gotoxy(40,8);write('nama:');readln(rdok.nama);
gotoxy(40,9);write('specialis:');readln(rdok.specialis);
seek (fdok,filesize(fdok));
write(fdok,rdok);
end;
gotoxy(40,10);write('input lagi[Y/T]:');readln(lg);
until upcase(lg)='T';
close(fdok);
end.
type dokter=record
kode :string[3];
nama :string[20];
specialis :string[20];
end;
var
fdok :file of dokter;
rdok :dokter;
i :byte;
xkd :string[3];
lg :char;
ketemu :Boolean;
procedure opendokter;
begin
clrscr;
assign(fdok,'c:\dokterr.dat');
{$I-} reset (fdok);
{$I+} if ioresult<>0 then rewrite(fdok);
end;
begin
clrscr;
opendokter;
repeat
i:=1;
ketemu:=false;
gotoxy(40,3);write('kode:');readln(xkd);
seek (fdok,0);
while not eof(fdok) do
begin
seek (fdok,i-1);read(fdok,rdok);
if rdok.kode=xkd then
begin
gotoxy(40,4);write('nama:',rdok.nama);
gotoxy(40,5);write('specialis:',rdok.specialis);
ketemu:=true;
end;
inc(i);
end;
rdok.kode:=xkd;
if not ketemu then
begin
gotoxy(40,8);write('nama:');readln(rdok.nama);
gotoxy(40,9);write('specialis:');readln(rdok.specialis);
seek (fdok,filesize(fdok));
write(fdok,rdok);
end;
gotoxy(40,10);write('input lagi[Y/T]:');readln(lg);
until upcase(lg)='T';
close(fdok);
end.