1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include<iostream>
#include<iomanip>
using namespace std;
main(){
char empid[100][12];
char fname[100][10], lastname[100][15], maritalstatus[100];
int hw[100];
double gp[100], np[100], hr[100], taxrate[100], taxamt[100];
int counter = 0;
int i;
cout<<"ENTER EMPLOYEE ID, FIRST NAME, LAST NAME, MARITAL STATUS, HOURS WORKED, HOURLY RATE"<<endl;
while(cin>>empid[counter]>>fname[counter]>>lastname[counter]>>maritalstatus[counter]>>hw[counter]>>hr[counter]){
counter=counter+1;
for (i=0; i<counter; i++){
gp[i] = hw[i] * hr [i];
} //end grosspay for loop
for (i=0;i<counter;i++){
if(gp[i]>500) taxrate[i] = .30;
else if (gp[i]>200) taxrate[i] = .20;
else taxrate[i] = .10;
}
for (i=0; i<counter; i++){
if (maritalstatus[i]= 'M', 'm') taxrate[i] +=0.0;
else if(maritalstatus[i]='S', 's') taxrate[i]=taxrate[i]+.05;
else if (maritalstatus[i] = 'H', 'h') if (taxrate[i]>0.05) taxrate[i] -=.05;
}
for (i=0; i<counter; i++){
taxamt[i] = gp[i] * taxrate[i];
}
for (i=0; i<counter; i++){
np[i] = gp [i] - taxamt [i];
}
cout<<endl;
cout<<setw(14)<<"ID"<<setw(11)<<"FN"<<setw(16)<<"LN"<<setw(2)<<"MS"<<setw(4)<<"HW"
<<setw(5)<<"HR"<<setw(6)<<"GROSS"<<setw(6)<<"TAX"<<setw(9)<<"NET"<<endl<<endl;
for (i=0; i<counter; i++){
setprecision(2); setiosflags(ios::fixed|ios::showpoint|ios::left);
cout<<setw(14)<<empid[i]<<setw(11)<<fname[i]<<setw(16)<<lastname[i]<<setw(2)<<maritalstatus[i]<<setw(4)<<hw[i]
<<setw(5)<<hr[i]<<setw(6)<<gp[i]<<setw(6)<<taxamt[i]<<setw(9)<<np[i]<<endl;
}//FOR
}
return 0;
}//MAIN
|