I think i'm calling it wrong too. it's at the bottom.
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
void ProcessPayroll(string [], int[], float[], float&, char&, float&, ifstream&, ofstream&);
void findMax(int, int);
int main()
{
ifstream infile; //opening infile
infile.open ("lab1.txt");
if(infile.fail())
{
cout << "failing to open input file\n"; //check to see if infile is open
getchar();
exit(1);
}
ofstream outfile; //opening outfile
outfile.open ("out1.txt");
if(outfile.fail())
{
cout << "failing to open output file\n"; //check to see if outfile is open
getchar();
exit(1);
}
const int i=15;
int hours[i];
float rate[i], gross, adjgross;
string name[i];
char bonus;
ProcessPayroll(name, hours, rate, gross, bonus, adjgross, infile, outfile); //calling ProcessPayroll function
getchar();
return 0;
}
void ProcessPayroll(string name[], int hours[], float rate[], float& gross, char& bonus, float& adjgross, ifstream& infile, ofstream& outfile)
//processes payroll
{
int j, i=0, count=0, y;
cout << "December 1997 Payroll\n\n" << " Name" << " " << "Hours" << " " << "Rate" << " " << "Gross" << " "
<< "Bonus" << " " << "Adjusted-Gross\n\n"; //shows headers
outfile << "Name" << " " << "Hours" << " " << "Rate" << " " << "Gross" << " "
<< "Bonus" << " " << "Adjusted-Gross\n\n"; //shows headers in outfile
while(infile >> name[i] >> rate[i] >> hours[i])
i++;
for(j=0; j<i; j++)
{
if(hours[j] < 30)
gross=(rate[j]-.25)*hours[j]; //calc gross pay
else
gross=rate[j]*hours[j];
if(hours[j] < 30)
rate[j]=(rate[j]-.25);
else
rate[j]=rate[j];
if(hours[j] > 45) //calc bonus code
bonus = 'Y';
else
bonus = 'N';
if(hours[j] > 45) //calc adjusted gross
adjgross = gross + 50;
else
adjgross = gross;
count = i ;
cout << setw(15) << name[j] << " "
<< setw(2) << hours[j] << " "
<< setw(5) << setiosflags(ios::fixed) << setprecision(2) << rate[j] << " "
<< setw(7) << setiosflags(ios::fixed) << setprecision(2) << gross << " "
<< setw(2) << bonus << " "
<< setw(7) << setiosflags(ios::fixed) << setprecision(2) << adjgross << "\n";
}
cout << "\nNumber of Employees\n\n" << count << "\n\n"
<< "Maximum Pay Rate\n\n" << findMax;
getchar ();
outfile.close();
return;
}
void findMax(int j, int y)
{
int y=0;
for(int j=1; j<Max_I_Val; j++)
{
if((rate[j] > rate[j-1]) && (rate[j] > y))
{
y=rate[j];
}
else if((rate[j-1] > rate[j] && (rate[j-1] > y))
{
y=rate[j-1];
}
}
}