I need to figure out how to add up the totals for all the columns except pate rate and employee name. I think Iam on the right track with line 35 but now Iam stuck.
Code:
#include <fstream>
#include <iostream>
#include "weekemp.h"
#include "compfun.h"
#include "string"
using namespace std;
int main()
{
weeklyEmp anEmp;
string fName, lName, name;
double hours, rate, totGross;
int exempts;
string status;
ifstream inFile("employee.dat");
if(! inFile)
{
cout << "**Error opening file 'employee.dat'" << endl;
}
else
{
//double net = emp.grossPay() - emp.incomeTax() - emp.FICATax();
decimals(cout, 2);
cout << " Pay Hours Gross Income FICA Net Employee" << endl;
cout << " Rate Worked Pay Tax Tax Pay Name" << endl;
cout << " ===== ====== ====== ====== ===== ====== ==============" << endl;
while(inFile >> fName >> lName >> hours >> rate >> exempts >> status)
{
name = lName + ", " + fName;
anEmp = weeklyEmp(name, hours, rate, exempts, status);
double net = anEmp.grossPay() - anEmp.incomeTax() - anEmp.FICATax();
totGross += anEmp.grossPay();
cout.width(6);
cout << rate;
cout.fill(' ');
cout.width(7);
cout << hours;
cout.width(8);
cout << anEmp.grossPay();
cout.width(8);
cout << anEmp.incomeTax();
cout.width(7);
cout << anEmp.FICATax();
cout.width(8);
cout << net;
cout << " ";
cout << anEmp.name();
cout << endl;
}
}
return 0;
}
Comment