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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
switch(unionCode[arrayIndex]){
case 1: unionDues[arrayIndex] = 15;
break;
case 2: unionDues[arrayIndex] = 25;
break;
case 3: unionDues[arrayIndex] = 35;
break;
}
cout << "Union dues = " << unionDues[arrayIndex] << endl;
netPay[arrayIndex] = grossPay[arrayIndex] - (totalTax[arrayIndex] + unionDues[arrayIndex]);
cout << "Net pay = " << netPay[arrayIndex] << endl;
return true;
}
double displayEmployeeResults(int empID[],int hoursWorked[],int payRate[],int unionCode[],char payrollType[],int arrayIndex,double regularPay[],double overtimePay[],double grossPay[],double netPay[],double stateTax[],double federalTax[],double totalTax[], double unionDues[]);
double displayEmployeeResults(int empID[],int hoursWorked[],int payRate[],int unionCode[],char payrollType[],int arrayIndex,double regularPay[],double overtimePay[],double grossPay[],double netPay[],double stateTax[],double federalTax[],double totalTax[], double unionDues[]){
int i;
cout <<" Entry1 Entry2 Entry3 Entry4"<<endl;
cout <<"Employee ID ";
for (i=0;i<4;i++){
cout<<" "<<empID[i]<<" "<<empID[i+1];
}
cout<<endl;
cout <<"Payroll Type ";
for (i=0;i<4;i++){
cout<<" "<<payrollType[i];
}
cout<<endl;
cout <<"Total Hours ";
for (i=0;i<4;i++){
cout<<" "<<hoursWorked[i];
}
cout<<endl;
cout <<"Pay Rate ";
for (i=0;i<4;i++){
cout<<" "<<payRate[i];
}
cout<<endl;
cout <<"Union Code ";
for (i=0;i<4;i++){
cout<<" "<<unionCode[i];
}
cout<<endl;
cout <<"Regular Pay ";
for (i=0;i<4;i++){
cout<<" "<<regularPay[i];
}
cout<<endl;
cout <<"Overtime Pay ";
for (i=0;i<4;i++){
cout<<" "<<overtimePay[i];
}
cout<<endl;
cout <<"Gross Pay ";
for (i=0;i<4;i++){
cout<<" "<<grossPay[i];
}
cout<<endl;
cout <<"State Tax ";
for (i=0;i<4;i++){
cout<<" "<<stateTax[i];
}
cout<<endl;
cout <<"Federal Tax ";
for (i=0;i<4;i++){
cout<<" "<<federalTax[i];
}
cout<<endl;
cout <<"Total Tax ";
for (i=0;i<4;i++){
cout<<" "<<totalTax[i];
}
cout<<endl;
cout <<"Union Dues ";
for (i=0;i<4;i++){
cout<<" "<<unionDues[i];
}
cout<<endl;
cout <<"Net Pay ";
for (i=0;i<4;i++){
cout<<" "<<netPay[i];
}
cout<<endl;
return true;
}
double displayPayrollSummaryResults();
int main(int argc, char *argv[])
{
int empID[4];
int hoursWorked[4];
int payRate[4];
int unionCode[4];
char payrollType[4];
double unionDues[4];
double regularPay[4];
double overtimePay[4];
double grossPay[4];
double stateTax[4];
double federalTax[4];
double totalTax[4];
double netPay[4];
int arrayIndex =0;
char carryOn;
cout << "Payroll Calculator" << endl;
do {
getInput(empID,hoursWorked,payRate,unionCode,payrollType,arrayIndex);
doCalculations(empID,hoursWorked,payRate,unionCode,payrollType,arrayIndex,regularPay,grossPay,overtimePay,stateTax,federalTax,totalTax,unionDues,netPay);
cout << "Would you like to calculate another employee's payroll? [Y/N]" << endl;
cin >> carryOn;
}
while (carryOn == 'Y' || carryOn == 'y');
while( carryOn != 'N' && carryOn != 'n' && carryOn != 'Y' && carryOn != 'y' ){
cout<< "Invalid Entry. Would you like to calculate another employee's payroll? [Y/N]"<<endl;
cin>> carryOn;
if (carryOn == 'N' || carryOn == 'n'){
displayEmployeeResults(empID,hoursWorked,payRate,unionCode,payrollType,arrayIndex,regularPay,grossPay,overtimePay,stateTax,federalTax,totalTax,unionDues,netPay);
}
system("PAUSE");
return EXIT_SUCCESS;
}
|