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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <iostream>
#include <iomanip>
using namespace std;
main(){
int hw[100]; //hours worked
double rp[100], gp[100], otp[100], np[100], TR[100], ta[100]; //regular pay, gross, overtime pay, net, taxes, tax rate,
double rh[100], oth[100], hr[100], otr[100]; //regular hours, overtime hours, hourly rate, overtime rate
char id[100][3], fn[100][14], ln[100][15], st[100]; //first name/last name/status-married, single, head of household
int counter = 0;
int i;
cout<<"Enter Employee First Name, Last Name, Status, SSN, Hours Worked, and Hourly Rate, and then press ctrl z"<<endl;
while(cin>>fn[counter]>>ln[counter]>>st[counter]>>id[counter]>>hw[counter]>>hr[counter])
counter=counter+1;
for (i=0; i<counter;i++)// Overtime hours and rate loop
{
if(hw[i] > 40)
{
oth[i] = hw[i] - 40;
otr[i] = oth[i] * hr[i] * 1.5;
}
else
{
oth[i]=0, otr[i]=0;
} // Overtime hours and rate loop
for (i=0; i<counter;i++) // Pay loop
{
rp[i] = hw[i] * hr[i];
if( oth[i] > 0)
otp[i] = (hw[i] - 40) * hr[i] * 1.5;
gp[i] = rp[i] + otp[i];
} // Pay loop
for (i=0; i<counter;i++) // Tax loop
{
if( gp[i] > 1000 ) TR[i] = 0.30;
else if( gp[i] > 800) TR[i] = 0.20;
else if( gp[i] > 500) TR[i] = 0.10;
else TR[i] = 0.0;
if (st[i]=='S') TR[i] = (TR[i] + .05);
else if (st[i]=='M') TR[i] = (TR[i] * 1);
else if (st[i]=='H') TR[i] = (TR[i] - .05);
} // Tax loop
for (i=0; i<counter;i++) //Net pay loop
{
ta[i] = gp[i] * TR[i];
np[i] = gp[i] * (1.0- TR[i]);
} // Net pay loop
cout<<endl<<endl<<setw(1)<<"DR. EBRAHIMI'S PAYROLL INSTITUTE"<<
endl<<endl;
cout<<setw(12)<<left<<"FIRST NAME"<<setw(10)<<left<<"LAST NAME"<<setw(5)<<"STAT"<<setw(4)<<"SSN"<<setw(4)<<"HW"<<
setw(6)<<"HR"<<setw(4)<<"OTH"<<setw(7)<<"OTP"<<setw(8)<<"REGP"<<setw(8)<<"GROSS"<<setw(5)<<"TAX"<<
setw(9)<<"NET"<<endl;
cout<<setw(12)<<left<<"=========="<<setw(10)<<"========= "<<setw(5)<<"===="<<setw(4)<<"==="<<setw(4)<<"==="<<
setw(6)<<"====="<<setw(4)<<"==="<<setw(7)<<"======"<<setw(8)<<"======="<<setw(8)<<"======="<<setw(5)<<"===="
<<setw(9)<<"======="<<endl;
for (i=0; i<counter;i++)
{
cout<<setw(12)<<fn[i]<<setw(10)<<ln[i]<<setw(5)
<<st[i]<<setw(4)<<id[i]<<setw(4)<<hw[i]
<<setw(6)<<hr[i]<<setw(4)<<oth[i]<<setw(7)
<<otp[i]<<setw(8)<<rp[i]<<setw(8)
<<gp[i]<<setw(5)<<TR[i]<<setw(9)<<np[i]
<<endl<<endl;
}
}
cin.get();
return 0;
|