Tuesday, 14 May 2013

Program C++: Menghitung Gaji Pegawai


#include <iostream.h>
#include <stdio.h>

struct pegawai { char nama[30];
char gol;
char nip [30];
float jamkerja; };
void main ()
{
char gol;
long int jamkerja,lembura,lemburc,lemburb,total;
int i,j;
cout<<"Masukkan Jumlah Data =";
cin>>j;
cout<<endl;
pegawai a[40];
for (i=0;i<j;i++)
{ cout<<"Data ke-"<<(i+1)<<endl;
cout<<"Nama :";
gets(a[i].nama);
cout<<"NIP :";
gets(a[i].nip);
cout<<"Golongan :";
cin>>gol;
cout<<"Jam Kerja :";
cin>>jamkerja;

if (gol=='a'||gol=='A')
{ cout<<"Gaji Pokok = Rp. 5000000"<<endl;
if(jamkerja>30)
{ lembura=jamkerja-30;
cout<<"Lembur : "<<lembura<<endl; }
total=5000000+(lembura*10000);
cout<<"Total Gaji = "<<total<<endl; }
else if (gol=='b'||gol=='B')
{ cout<<"Gaji Pokok = Rp 3000000"<<endl;
if (jamkerja>30)
{ lemburb=jamkerja-30;
cout<<"Lembur : "<<lemburb<<endl; }
total=3000000+(lemburb*10000);
cout<<"Total Gaji = "<<total<<endl; }
else if (gol=='c'||gol=='C')
{  cout<<"Gaji Pokok = Rp 1000000"<<endl;
if (jamkerja>30)
{ lemburc=jamkerja-30;
cout<<"Lembur : "<<lemburc<<endl; }
total=1000000+(lemburc*10000);
cout<<"Total Gaji = "<<total<<endl;  }
}
}

No comments:

Post a Comment