contoh : listing program pascal dengan menggunakan fungsi..
program tunjangan; uses wincrt; var nm,jab,no :string; gaj,ti,ta,tgaj:real; stat,jmlank :integer; function gajibersih (gaji,tunjangan_anak,tunjangan_istri,totalgaji :real):real; begin gajibersih:=gaji+tunjangan_anak+tunjangan_istri; end; begin writeln('================================================='); writeln('=TUGAS PERHITUNGAN GAJI DAN TUNJANGAN ANAK ISTRI='); writeln('=Nama :Muhammad Asrir NIM :2010020112 ='); writeln('================================================='); writeln('= Masukkan data sesuai pada ketentuan berikut ='); writeln('================================================='); writeln('======Status====================================='); writeln(' 1. Kawin '); writeln(' 2. Tidak Kawin '); writeln('================================================='); writeln; writeln; write ('nomor induk karyawan : ');readln(no); write ('nama pegawai : ');readln(nm); write ('jabatan pegawai : ');readln(jab); write ('Gaji pokok : Rp,');readln(gaj); write ('status perkawinan : ');readln(stat); case stat of 1 :begin ti :=(15/100)*gaj; write ('jumlah anak : ');readln(jmlank); if (jmlank >=3) then ta :=(5/100)*gaj else if (jmlank <3) then ta :=0; end; 2 :begin ti :=0; ta :=0; end; end; begin writeln; writeln('=================oO SLIP GAJI Oo================='); writeln; writeln ('Nama : ',nm); writeln ('No Karyawan : ',no); writeln ('Jabatan : ',jab); writeln ('+===============================================+'); writeln ('| Rincian Gaji | Jumlah |'); writeln ('+===============================================+'); writeln ('| Gaji Pokok : | Rp ',gaj:8:0,' |'); writeln ('| Tunjangan Anak : | Rp ',ta:8:0,' |'); writeln ('| Tunjangan Istri : | Rp ',ti:8:0,' |'); writeln ('| | |'); writeln ('+===============================================+'); writeln ('| Total Gaji Bersih : | Rp ',gajibersih (gaj,ti,ta,tgaj):8:0,' |'); writeln ('+===============================================+'); readln; end; end.
0 komentar:
Posting Komentar