Beberapa Contoh program Pascal

program jum_bil;
uses wincrt;
var
i, jum,bil: integer;
begin
jum:=0; {inisialisasi}
for i:=1 to 5 do
begin
write(‘Masukkan Bilangan = ‘);readln(bil);
jum:=jum+bil;
end;
writeln(‘Jumlah Bilangan = ‘,jum);
end.

program jum_bil2;
uses wincrt;
var
i, n: integer;
jum, bil: real;
begin
write(‘Banyak bilangan :  ’);read(n);
jum := 0;
For i:= 1 to n do
begin
write(‘Masukkan Bilangan ‘,i, ‘=’);read(bil);
jum := jum+bil;
end;
writeln(‘Jum = ‘,jum:0:2);
end.

program contoh_3;
uses wincrt;
var
n, i : integer;
rata : real;
jum, bil : integer;
begin
Write(‘Masukkan nilai N = ‘);readln(n);
writeln (‘Nilai N adalah= ‘,n);writeln;
for i := 1 to n do
begin
write(‘Masukkan bilangan : ‘);read(bil);
jum := jum+bil;
end;
rata := jum/n;writeln;
writeln(‘Jumlahnya adalah : ‘,jum);
writeln(‘Nilai rata-ratanya :’, rata:0:2);
end.

program pembuatan_record;
uses crt;
procedure garis;
begin
writeln(’==============================================’);
end;
type
reckaryawan=record
jab,nip,nama:string;
gol:integer;
gapok,tunj:real;
end;
var pegawai:reckaryawan;
total:real;
begin
clrscr;
writeln(’ LAPORAN PERHITUNGAN GAJI KARYAWAN PT MAJU TAK GENTAR’);
garis;
writeln;
write(’Masukan NIP Karyawan : ‘);readln(pegawai.nip);
write(’Masukan Nama Karyawan : ‘);readln(pegawai.nama);
write(’Golongan[1/2/3] : ‘);readln(pegawai.gol);
garis;
case pegawai.gol of
1:
begin
pegawai.jab:=’Staf dan Tetap’;
pegawai.gapok:=900000;
end;
2:
begin
pegawai.jab:=’Staf dan Kontrak’;
pegawai.gapok:=700000;
end;
3:
begin
pegawai.jab:=’Kontrak’;
pegawai.gapok:=500000;
end;
end;
if pegawai.jab=’Staf dan Tetap’ then
pegawai.tunj:=25/100*pegawai.gapok
else
if pegawai.jab=’Staf dan Kontrak’ then
pegawai.tunj:=10/100*pegawai.gapok
else
pegawai.tunj:=0;
total:=(pegawai.gapok)+(pegawai.tunj);
writeln(’Jabatan Karyawan : ‘,pegawai.jab);
writeln(’Gaji Pokok : ‘,pegawai.gapok:8:0);
writeln(’Tunjangan : ‘,pegawai.tunj:8:0);
garis;
writeln(’Total Gaji Karyawan : ‘,total:8:0);
readln;
end.

Program Gaji_Tunjangan_dan_Pajak;
{Menghitung jumlah gaji berdasarkan golongan, tunjangan anak dan istri, total gaji setelah pajak}
Uses wincrt;
var
nama,jab    : string[20];
noin        : string[10];
golgaj           : char;
stmerit, jmlanak : integer;
gaj,tjbini,tjanak,pajgaj,jmlpajgaj,jmltjgaj,tolgaj,tolgajstpaj : real;
Begin
clrscr;
Writeln (‘=============================================’);
Writeln (‘PERHITUNGAN GAJI DAN TUNJANGAN DAN PAJAK GAJI’);
Writeln (‘=============================================’);
Writeln;
Writeln (‘Isikan Data anda sesuai ketentuan berikut ini : ‘);
Writeln (‘———————————————– ‘);
Writeln;
Writeln (‘Golongan Gaji :            Status Perkawinan : ‘);
Writeln (‘a. Rp. 2.000.000.00        1. Kawin ‘);
Writeln (‘b. Rp. 2.500.000.00        2. Belum kawin’);
Writeln (‘c. Rp. 3.000.000.00        3. Cerai ‘);
Writeln;
Write (‘Masukkan No karyawan          : ‘);readln (noin);
Write (‘Masukkan nama anda            : ‘);readln (nama);
Write (‘Masukkan Jabatan              : ‘);readln (jab);
Write (‘Masukkan Golongan gaji anda   : ‘);readln (golgaj);
case golgaj of
‘a’ : begin
gaj := 2000000;
pajgaj := (2/100);
Write (‘Status Perkawinan anda : ‘);readln (stmerit);
case stmerit of
1 : begin
tjbini := (5/100)*gaj;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
2 : begin
tjbini := 0;
tjanak := 0;
end;
3 : begin
tjbini := 0;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
else
Writeln;
Writeln (‘================================================================’);
Writeln;
Writeln (‘Tunjangan tidak terhitung karena tidak terinput dengan benar !!!’);
end;
end;
‘b’ : begin
gaj := 2500000;
pajgaj := (2.5/100);
Write (‘Status Perkawinan anda : ‘);readln (stmerit);
case stmerit of
1 : begin
tjbini := (5/100)*gaj;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
2 : begin
tjbini := 0;
tjanak := 0;
end;
3 : begin
tjbini := 0;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
else
writeln;
Writeln (‘================================================================’);
Writeln;
Writeln (‘Tunjangan tidak terhitung karena tidak terinput dengan benar !!!’);
end;
end;
‘c’ : begin
gaj := 3000000;
pajgaj := (3/100);
Write (‘Status Perkawinan anda : ‘);readln (stmerit);
case stmerit of
1 : begin
tjbini := (5/100)*gaj;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
2 : begin
tjbini := 0;
tjanak := 0;
end;
3 : begin
tjbini := 0;
Write (‘Jumlah anak         : ‘);readln (jmlanak);
if jmlanak <= 3 then
tjanak := jmlanak*((2/100)*gaj)
else
tjanak := 3*((2/100)*gaj);
end;
else
writeln;
Writeln (‘================================================================’);
Writeln;
Writeln (‘Tunjangan tidak terhitung karena tidak terinput dengan benar !!!’);
end;
end;
else
Writeln;
Writeln (‘=======================================’);
Writeln;
Writeln (‘Maaf, Golongan Gaji tidak terdaftar !!!’);
Writeln;
end;
jmltjgaj   := tjbini+tjanak;
tolgaj     := gaj+jmltjgaj;
jmlpajgaj  := tolgaj*pajgaj;
tolgajstpaj := tolgaj-jmlpajgaj;
Writeln;
Writeln (‘SLIP GAJI ———————————–> ‘);
Writeln;
Writeln (‘Nama         : ‘,nama);
Writeln (‘No Karyawan  : ‘,noin);
Writeln (‘Jabatan      : ‘,jab);
Writeln (‘+============================================+’);
Writeln (‘| Rincian                    | Jumlah        | ‘);
Writeln (‘+============================================+’);
Writeln (‘| Besar Gaji               : | Rp.’,gaj:8:0,’   |’);
Writeln (‘| Tunjangan istri          : | Rp.’,tjbini:8:0,’   |’);
Writeln (‘| Tunjangan anak           : | Rp.’,tjanak:8:0,’   |’);
Writeln (‘| Total gaji               : | Rp.’,tolgaj:8:0,’   |’);
Writeln (‘| Pajak gaji               : | Rp.’,jmlpajgaj:8:0,’   |’);
Writeln (‘+—————————-+—————+’);
Writeln (‘| Total gaji setelah pajak : | Rp.’,tolgajstpaj:8:0,’   |’);
Writeln (‘+—————————-+—————+’);
Writeln (‘Program by, w1r0’);
readln;
End.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s