// the output is coming out incorrectly. any suggestions?
//here is what i have
// Lab 4 read and calculation file/input
// This program will read the data in the input file
// used by grosspayMinustaxFileCode
#include <iostream>
#include <fstream>
using namespace std;
int main()
// this is the error message it displays if not working right to EXIT
{
ifstream inFile;
int employee = 1;// I am trying to get loop initialized
int exemptions, taxbracket; //the read other file cue
double hours, overtime, payrate, grosspay, netpay, rate, tax;
inFile.open("readGrosspayMinustax.cpp");
if (inFile.fail())
{
cerr << "error opening input file.\n\n";
system("pause");
exit(1);
}
// cout << "Enter an integer: ";
while (inFile >> hours)
inFile >> payrate;
if (hours > 40)
{
overtime = hours - 40;
hours = 40;
}
else
overtime = 0;
grosspay = hours * payrate + overtime * payrate * 1.5;
cout << grosspay;
inFile >> taxbracket;
if (taxbracket == 1)
rate = .13;
else if (taxbracket == 2)
rate = .27;
else
rate = .35;
inFile >> exemptions;
{
tax = grosspay * (rate - .01 * exemptions);
netpay = grosspay - tax;
employee++;
cout << employee << hours << payrate << taxbracket << exemptions << endl;
cout << grosspay << tax << netpay;
}
inFile.close();
system("pause");
return 0;
}
/*\\ This is the read file where the fin.in file will derived data.
50.00 20.00 2 3
40.00 10.00 1 0
10.00 40.00 3 5
40.00 11.25 1 2
output 1.72093e-01521.6211e-3071.06159e+29222936723998968
1.72093e-015-6.88189e-0116.88206e-011Press any key to continue . . .*/