Mlente Banget

Posts Tagged ‘tugas pascal


Tugas Pascal menghitung gaji dan tunjangan anak/istri :

uses wincrt;

var
nama,jab:string[25];
noin    :string[10];
gol     :char;
stat,jmlanak:integer;
gaj,tist,tank,jmltgaj,tlgaj:real;

begin
clrscr;
writeln(‘===============================================’);
writeln(‘TUGAS PERHITUNGAN GAJI DAN TUNJANGAN ANAK ISTRI’);
writeln(‘     Nama : Mahasiswa NIM : xxxxxxxxx                           ‘);
writeln(‘===============================================’);
writeln;
writeln(‘  Masukkan data sesuai pada ketentuan berikut  ‘);
writeln(‘+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+’);
writeln;
writeln(‘Golongan Gaji :           Status :’);
writeln(‘a. Rp 1,000,000.00        1. Kawin’);
writeln(‘b. Rp 1,500,000.00        2. Tidak Kawin’);
writeln(‘c. Rp 2,000,000.00’);
writeln;
write(‘Nomor Induk Karyawan : ‘);readln(noin);
write(‘Nama Pegawai         : ‘);readln(nama);
write(‘Jabatan Pegawai      : ‘);readln(jab);
write(‘Golongan Gaji        : ‘);readln(gol);

case gol of
‘a’ : begin
gaj :=1000000;
write(‘Status Perkawinan    : ‘);readln(stat);
case stat of
1 : begin
tist := (10/100)*gaj;
write(‘Jumlah anak          : ‘);readln(jmlanak);
if jmlanak =1 then
tank := (10/100)*gaj
else
if jmlanak =2 then
tank := (15/100)*gaj
else
tank := (20/100)*gaj
end;
2 : begin
tist := 0;
tank := 0;
end;

end;
end;
‘b’ : begin
gaj :=1500000;
write(‘Status Perkawinan    : ‘);readln(stat);
case stat of
1 : begin
tist := (15/100)*gaj;
write(‘Jumlah anak          : ‘);readln(jmlanak);
if jmlanak =1 then
tank :=(10/100)*gaj
else
if jmlanak =2 then
tank :=(15/100)*gaj
else
tank :=(20/100)*gaj
end;
2 : begin
tist := 0;
tank := 0;
end;

end;
end;
‘c’ : begin
gaj :=2000000;
write(‘Status Perkawinan    : ‘);readln(stat);
case stat of
1 : begin
tist := (20/100)*gaj;
write(‘Jumlah anak          : ‘);readln(jmlanak);
if jmlanak =1 then
tank :=(10/100)*gaj
else
if jmlanak =2 then
tank :=(15/100)*gaj
else
tank :=(20/100)*gaj
end;
2 : begin
tist :=0;
tank :=0;
end;

end;
end;

end;

tlgaj      := gaj+tank+tist;

writeln;
writeln(‘=================oO SLIP GAJI Oo=================’);
writeln;
writeln (‘Nama          : ‘,nama);
writeln (‘No Karyawan   : ‘,noin);
writeln (‘Jabatan       : ‘,jab);
writeln (‘+===============================================+’);
writeln (‘|       Rincian Gaji         |      Jumlah      |’);
writeln (‘+===============================================+’);
writeln (‘| Gaji Pokok               : | Rp ‘,gaj:8:0,’      |’);
writeln (‘| Tunjangan Anak           : | Rp ‘,tank:8:0,’      |’);
writeln (‘| Tunjangan Istri          : | Rp ‘,tist:8:0,’      |’);
writeln (‘|                            |                  |’);
writeln (‘+———————————————–+’);
writeln (‘| Total Gaji Bersih        : | Rp ‘,tlgaj:8:0,’      |’);
writeln (‘+———————————————–+’);

readln;

end.

Selamat Mencoba


Tugas pascal menghitung nilai faktorial :

uses wincrt;
function fak(x:word):real;
begin
if x=0 then fak:=1
else fak:=x*fak(x-1);
end;

var n:word;z:real;
begin
writeln(‘=========================================’);
writeln(‘Tugas Algoritma – Nama/NIM Mahasiswa’);
writeln(‘=========================================’);
writeln;
write(‘Hitung Nilai Faktorial dari : ‘);
readln(n);
z:=fak(n);
writeln(‘Nilai Faktorial Dari ‘,n,’ adalah’,z:4:0);
writeln;
writeln(‘=========================================’);
end.

Apabila digambarkan sebagai berikut :

fak(5) => x<>0 => fak=5*fak(4) => fak=5*24 => 120
fak(4) => x<>0 => fak=4*abc(3) => fak=4*6 => 24
fak(31) => x<>0 => fak=3*abc(2) => fak=3*2 => 6
fak(2) => x<>0 => fak=2*abc(1) => fak=2*1 => 2
fak(1) => x=0 => fak=1 => fak=1 => 1
Proses rekursi dihentikan karena b=0 dan abc(5,0)=1.
Bila disimpulkan : fak(5) = 5*(4*(3*(2*(1))))
= 120

Selamat Mencoba


About Me

Unknown unordinary creature
 






June 2017
M T W T F S S
« Sep    
 1234
567891011
12131415161718
19202122232425
2627282930  

Blog Stats

  • 132,391 hits

Your Information

Tracker