I think I understand functions but maybe not. I am getting an error on my open files function. I looked around a bit and didn't find any answers. The compile dies on line 36 'char' should be preceded by ')' I don't know whats wrong. Any help would be appreciated.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
//function prototypes
void OpenFiles (ifstream& input, char lettercode, double GPA);
void Initialize (int fcount, int mcount, double f_gpa, double m_gpa);
void Sum_GPA (double& sumFemaleGPA, double& sumMaleGPA, int& fcount, int& mcount);
void Average_GPA (double& fgpa_aver, double& mgpa_aver, int& fcount, int& mcount);
void Print_Results (char lettercode, double mgpa_aver, double fgpa_aver, int fcount, int mcount);
const int eof = -999;
int main ()
{
//Step 1
char lettercode; //Male or Female letter
double GPA; // GPA from file
double f_avg; //average for female
double m_avg; //average for male
double fcount; //female counter
double mcount; //male counter
ifstream input; //input stream variable
ofstream outfile; //output stream variable
OpenFiles(char lettercode, double GPA); // Line 36
Initialize(double f_gpa, double m_gpa, double& F_GPA_Average, double& M_GPA_Average);
while (!eof)
{
Sum_GPA(ifstream& input, char lettercode, int& fcount, int& mcount, double& fGPA, double& mGPA);
Average_GPA(double& fgpa_aver, double& mgpa_aver);
} // end while
Print_Results (ofstream outfile, char lettercode, double mgpa_aver, double fgpa_aver, int fcount, int mcount);
input.close();
outfile.close();
return 0;
}
void OpenFile(char lettercode, double GPA)
{
ifstream input;
input.open("ch7_ex4.txt");
if (!input)
{
cout << "Unable to open file." << endl;
cout << "Program terminates." << endl;
return 1;
}
ofstream output;
output.open ("Avr_GPA.txt");
outfile << fixed << showpoint << setprecision(2);
}
void Initialize (int fcount, int mcount, double f_gpa, double m_gpa)
{
f_gpa = 0.0;
m_gpa = 0.0;
fcount = 0;
mcount = 0;
}
void Sum_GPA(double& f_gpa, double& m_gpa, int& fcount, int& mcount)
{
input (lettercode, GPA);
double fGPA;
double mGPA;
char lettercode;
switch (lettercode)
{
case 'f':
case 'F':
fGPA += GPA;
fcount ++;
break;
case 'm':
case 'M':
mGPA += GPA;
mcount ++;
break;
} // end switch
} // end Sum_GPA function
void Average_GPA(double& fgpa_aver, double& mgpa_aver)
{
int fcount;
int mcount;
fgpa_aver = fGPA/fcount;
mgpa_aver = mGPA/mcount;
} //end Average_GPA function
void Print_Results (ofstream outfile, char lettercode, double mgpa_aver, double fgpa_aver, int fcount, int mcount)
{
outfile << "Number of Female students: " << fcount << endl;
ouftile << "Female students average: " << fgpa_aver << endl;
outfile << "Number of Male students: " << mcount << endl;
outfile << "Male students average: " << mgpa_aver << endl;
}