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
|
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
void payRoll(string fName[], string lName[], double payRate[], double hoursWorked[], int count)
{
double overTime, grossPay, netPay, tax = .10;
for(int a=0;a<count;a++)
{
tax = .10;
if(hoursWorked[a]>40)
{
overTime = payRate[a] * 1.5 * (hoursWorked[a] - 40);
grossPay = overTime + 40 * payRate[a];
}
else
grossPay = hoursWorked[a] * payRate[a];
tax = grossPay * tax;
netPay = grossPay - tax;
cout << "First Name: " << fName[a] << endl;
cout << "Last Name: " << lName[a] << endl;
cout << "Pay rate: $" << payRate[a] << endl;
cout << "Hours Worked: " << hoursWorked[a] << endl;
cout << "Gross Pay: $" << grossPay << endl;
cout << "Taxes Witheld: $" << tax << endl;
cout << "Net Pay: $" << netPay << endl << endl << endl;
}
}
int main()
{
ifstream iFile;
iFile.open("payroll.txt");
const int n = 50;
string fName[n], lName[n];
int count=0;
double payRate[n], hoursWorked[n], overTime;
double grossPay, netPay, tax = .10;
cout << fixed << showpoint;
cout << setprecision(2);
while(!iFile.eof())
{
tax = .10;
iFile >> fName[count];
iFile >> lName[count];
iFile >> payRate[count];
iFile >> hoursWorked[count];
count++;
}
payRoll(fName, lName, payRate, hoursWorked, count);
system("pause");
return 0;
}
|