Code:
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
void main()
{
//Declare and open files
ifstream PayinFile;
ofstream PayoutFile;
PayinFile.open ("C: PayinFile.txt");
PayoutFile.open ("C: PayOut.txt");
//Declare variables
char Cat1,Cat2,Cat3;
float Pay1,Pay2,Pay3;
int EmpNr1,EmpNr2,EmpNr3;
float avgNum;
//Read in data from file inData
PayinFile>> Cat1 >> Pay1 >>EmpNr1
>> Cat2 >> Pay2 >> EmpNr2
>> Cat3 >> Pay3 >> EmpNr3;
//Calculations
avgNum = (EmpNr1 + EmpNr2 + EmpNr3)/3;
PayoutFile << fixed << setprecision(2)
<< "The average number of Employees is " << avgNum << " ." << endl;
PayinFile.close();
PayoutFile.close();
}
Met with the professor today for a few minutes and got this far with the assignment. I am still having the problem, however, the results are not what they are supposed to be. What am I doing wrong???? I'm not looking for a solution to the problem just how do I get to the correct solution. Thank you much.