Oke lansung saja lihat script berikut.!
Soal :
Sebuah perusahaan akan menghitung total gaji karyawan dengan ketentuan sbb :
Tunjangan :
Nikah : 75000
Belum : 20000
Bonus :
gol i = 150000
gol ii = 175000
gol iii = 200000
gaji pokok :
gol i = 2000000
gol ii = 2750000
gol iii = 3500000
total gaji = gaji pokok + bonus + tunjangan
Buatlah program menggunakan c++.
Jawab :
#include
#include
//NAMA : RIDWAN ABDULAH
//NIM : 12131279
//STIMIK EL RAHMA
class xpenggajian
{
public:
char golongan[4];
char menikah;
char nama[30];
long gaji_pokok()
{
long b;
if ( !strcmp ( golongan, "I" ))
{
b = 2000000;
}
else if ( !strcmp ( golongan, "II" ))
{
b = 2750000;
}
else if ( !strcmp ( golongan, "III" ))
{
b = 3500000;
}
else
{
b = 0;
}
return b;
}
long tunjangan_anakistri()
{
long c;
if ( menikah == 'B' )
{
c = 20000;
}
else if ( menikah == 'M' )
{
c = 75000;
}
else
{
c = 0;
}
return c;
}
long bonus()
{
long d;
if ( !strcmp ( golongan, "I" ))
{
d = 150000;
}
else if ( !strcmp ( golongan, "II" ))
{
d = 175000;
}
else if ( !strcmp ( golongan, "III" ))
{
d = 200000;
}
else
{
d = 0;
}
return d;
}
long total_gajipokok()
{
long i;
i = gaji_pokok() + tunjangan_anakistri() + bonus();
return i;
}
};
main()
{
xpenggajian p;
cout<<"\n";
cout<<" PROGRAM PENGGAJIAN KARYAWAN \n";
cout<<" CV.ONEMEDIA \n";
cout<<" =======================================\n";
cout<<" NAMA : "; cin>>p.nama;
cout<<" MENIKAH (M/B) : "; cin>>p.menikah;
cout<<" GOLONGAN (I/II/III) : "; cin>>p.golongan;
clrscr();
cout<<"\n";
cout<<" PROGRAM PENGGAJIAN KARYAWAN \n";
cout<<" CV.ONEMEDIA \n";
cout<<" =======================================\n";
cout<<" NAMA : " << p.nama <<"\n";
cout<<" MENIKAH (M/B) : " << p.menikah <<"\n";
cout<<" GOLONGAN (I/II/III) : " << p.golongan <<"\n";
cout<<" ---------------------------------------\n";
cout<<" GAJI POKOK : Rp. " << p.gaji_pokok() <<"\n";
cout<<" BONUS : Rp. " << p.bonus() <<"\n";
cout<<" TUNJANGAN ANAK ISTRI : Rp. " << p.tunjangan_anakistri() <<"\n";
cout<<" ---------------------------------------\n";
cout<<" TOTAL GAJI : Rp. " << p.total_gajipokok() <<"\n";
getch();
}
0 komentar