Code
// Kolten Minix CO 127 10/26/14
#include <iostream>
#include <fstream>
#include "compfun.h"
#include "weeklyEmp.h"
using namespace std;
int main(){
// Create variables to hold lastName, firstName, name, hours, rate, exemptions filingStatus and a weeklyEmp
string lastName, firstName, name, filingStatus, emp;
double hours, rate, totRate;
int exemptions;
weeklyEmp anEmp;
double incomeTax = 0.0;
double grossPay = 0.0;
double FICATax = 0.0;
ifstream inFile("C:\\Users\\Kolt\\Documents\\Visual Studio 2013\\Projects\\payroll9c");
if (!inFile)
{
cout << "Failed to find the file employee.dat" << endl;
}
else{
decimals(cout, 2);
}
//Set output format to be two decimal places and use cout to create the report heading as displayed below:cout << "Employee Name: " << emp.name() << endl;
cout << " Pay Rate " << " Gross Pay " << " Income Tax " << " FICA Tax " << " Net Pay " << " Employee Name " << endl;
cout << " =========== " << " ============ " << " =========== " << " ========== " << " ========== " << " ========== " << endl;
//Initialize all total variables used to zero. You will also need variables to hold the totValue of hours rate, etc. Each variable must be initialized,
//so for example totHours = 0.0;
//Process data until end of file by using a while loop, see page 352-353 for an example of using the end of file event to terminate the loop
while (inFile >> firstName >> lastName >> hours >> rate >> exemptions >> filingStatus){
name = lastName + "," + firstName;
anEmp = weeklyEmp(name, hours, rate, exemptions, filingStatus);
}
}
employee.dat
Code
Ross Greene 38.0 10.45 4 M
Mary Kristner 42.0 12.00 0 S
Mellisa Nicholson 30.5 9.99 1 S
Samuel Woodley 40.0 11.57 1 S
output from program
Code
Failed to find the file employee.dat
Pay Rate Gross Pay Income Tax FICA Tax Net Pay
Employee Name
=========== ============ =========== ========== ==========
==========
Press any key to continue . . .
1. I don't understand why its displaying Pay rate and employee name stacked on eachother..
2. its not finding my .dat file which is in C:\Users\Kolt\Documents\Visual Studio 2013\Projects\payroll9c