Saturday, 20 June 2015

Program Penggajian pegawai dengan C++ (record dan Array)



#include "conio.h"
#include "iostream.h"
#include "string.h"

struct datamns {
char nip [8];
char gol [5];
char status [10];
int nilai ;
} recmhs [15];
void main (){
int jumdata =2,i,hasil;
char *nama;
float pajak,tunjang;
long gaji,bersih ;
clrscr ();
for (i=0;i<jumdata;i++){
cout<<"\nInformasi penggajian pegawai";
cout<<"\nNIP    :";cin>>recmhs[i].nip;
cout<<"Golongan  :";cin>>recmhs[i].gol;
cout<<"Status    :";cin>>recmhs[i].status;

}
clrscr();
cout<<"Informasi penggajian pegawai";
cout<<"\n-----------------------------------------------------------------------------";
cout<<"\nNO  NIP  Nama Golongan  Gaji Pokok   Status   Tunjangan   Pajak   Gaji Bersih";
cout<<"\n-----------------------------------------------------------------------------";
for (i=0;i<jumdata;i++){
hasil=strcmp(recmhs[i].nip,"1101");
if (hasil==0) nama="dian";
hasil=strcmp(recmhs[i].nip,"1102");
if (hasil==0) nama="eko";
hasil=strcmp(recmhs[i].nip,"1103");
if (hasil==0) nama="Dian";
hasil=strcmp(recmhs[i].nip,"1104");
if (hasil==0) nama="sari" ;
hasil=strcmp(recmhs[i].nip,"1105");
if (hasil==0) nama="rani";

hasil=strcmp(recmhs[i].gol,"3A");
if (hasil==0) gaji = 1500000;
hasil=strcmp(recmhs[i].gol,"3B");
if (hasil==0) gaji = 2500000;
hasil=strcmp(recmhs[i].gol,"3C");
if (hasil==0) gaji = 3500000;

hasil=strcmp(recmhs[i].status,"menikah");
if (hasil==0) tunjang = 0.10* gaji;
hasil=strcmp(recmhs[i].status,"lajang");
if (hasil==0) tunjang = 0;

pajak = 0.03 *gaji;
bersih=gaji+tunjang-pajak;

gotoxy (1,5+i);cout<<i<<"  " <<recmhs[i].nip;
gotoxy (10,5+i);cout<<nama;
gotoxy (18,5+i);cout<<recmhs[i].gol;
gotoxy (25,5+i);cout<<gaji;
gotoxy (38,5+i);cout<<recmhs[i].status;
gotoxy (48,5+i);cout<<tunjang;
gotoxy (59,5+i);cout<<pajak;
gotoxy (69,5+i);cout<<bersih;


}
cout<<"\n------------------------------------------------------------------------------";
}

No comments :

Post a Comment