My assignment is to create a program computing all kinds of employee data. Just beginning, trying to put together the basis for the rest of it, here's my code:
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
int GrossPay(int,int);
double Tax(int);
int main ()
{
ifstream empdata;
empdata.open("employees");
int totEmpl, ID, hrlPay, hrsWrk;
int GrP = 0;
double Tx = 0;
int Net = GrP-Tx;
cout.setf(ios::fixed,ios::floatfield);
cout << setw(2) << "#" << "\t" << setw(5) << "ID" << "\t"
<< setw(5) << "$/Hr" << "\t" << setw(5) << "#/Hrs" << "\t"
<< setw(5) << "Gross" << "\t" << setw(5) << "Tax" << "\t"
<< setw(5) << "Net" << endl << endl;
empdata >> totEmpl;
for (int count=1; count<=totEmpl; count++) {
empdata >> ID >> hrlPay >> hrsWrk;
GrP = GrossPay(hrlPay,hrsWrk);
Tx = Tax(GrP);
cout << setw(2) << count << "\t" << setw(5) << ID << "\t"
<< setw(5) << hrlPay << "\t" << setw(5) << hrsWrk << "\t"
<< setw(5) << GrP << "\t" << setw(5) << Tx << "\t"
<< setw(5) << Net << endl << endl;
}
empdata.close();
return 0;
}
int GrossPay (int r, int w) {
if (w<=40)
return r;
else return r*2;
}
double Tax (int gp) {
char tax;
if (gp>500)
tax=10;
else if (gp>=200 && gp<=500)
tax=5;
else tax=0;
}
Why won't it work.