My program is supposed to open files, initialize variables, use the functions sumGrades, averageGrade and printResults. I am having some errors and was hoping someone could help me out. To begin with some errors I'm getting are:
line 10- two few arguments to function 'void printResult(int, int, float, float, float, float)'
line 33- at this point in file
in function 'void OpenFiles(char, float)':
line 71 'MaleGPA' undeclared (first use this function)
line 73 'avgMaleGPA' undeclared (first use this function)
line 73 'femGPA' undeclared (first use this function)
line 76 'FemGPA' undeclared (first use this function)
line 76 'GPA' undeclared (first use this function)
line 77 'countFem' undeclared (first use this function)
line 78 'avgFemGPA' undeclared (first use this function)
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void OpenFiles(char ch, float gpa);
void initialize(int countFemale, int countMale, float sumFemGPA, float sumMaleGPA);
void sumGrades(int countFemale, int countMale, float sumMaleGPA, float sumFemGPA);
void averageGrades(float avgFemGPA, float avgMaleGPA);
void printResult(int countFemale, int countMale, float avgMaleGPA, float avgFemGPA, float sumMaleGPA, float sumFemGPA);
int main ()
{
ifstream inFile;
ofstream outFile;
char ch;
float gpa;
float avgFemGPA, avgMaleGPA;
int countFemale, countMale;
float FemGPA, MaleGPA, sumFemGPA, sumMaleGPA;
initialize(countFemale, countMale, sumFemGPA, sumMaleGPA);
OpenFiles(ch, gpa);
while(!inFile.eof())
{
sumGrades(countFemale, countMale, sumMaleGPA, sumFemGPA);
inFile >> ch >> gpa;
averageGrades(avgFemGPA, avgMaleGPA);
}
printResult(countFemale, countMale, sumMaleGPA, sumFemGPA);
}
void OpenFiles(char ch, float gpa)
{
ifstream inFile;
ofstream outFile;
inFile.open ("Ch7_Ex4Data.txt");
outFile.open ("Ch7_Ex4Out.txt");
if(!inFile)
{
cout << "Cannot open input file." << endl;
}
inFile.get(ch);
inFile >> gpa;
inFile.eof();
outFile << fixed << showpoint;
outFile << setprecision(2);
}
void initialize(int countFemale, int countMale, float sumFemGPA, float sumMaleGPA)
{
float FemGPA = 0.0;
float MaleGPA = 0.0;
countFemale = 0;
countMale = 0;
}
void sumGrades(int countFemale, int countMale, float sumMaleGPA, float sumFemGPA)
{
char ch;
float gpa;
OpenFiles(ch, gpa);
switch (ch)
{
case 'M':
case 'm': MaleGPA = MaleGPA + gpa;
countMale++;
avgMaleGPA = MaleGPA / countMale;
break;
case 'F':
case 'f': FemGPA = FemGPA + GPA;
countFem++;
avgFemGPA = FemGpa / countFem;
break;
default: cout << "Invalid Gender" << endl;
return;
}
}
void averageGrades(float avgFemGPA, float avgMaleGPA)
{
float FemGPA, MaleGPA;
int countFem, int CountMale;
sumGrades (countFemale, countMale, sumMaleGPA, sumFemGPA)
avgFemGPA = FemGPA / countFem;
avgMaleGPA = MaleGPA / countMale;
}
void printResults(int countFem, countMale, float avgFemGPA, float avgMaleGPA)
{
ofstream outFile;
out << "Number of female students = " << countFem << endl;
out << "Average female GPA = " << avgFemGPA << endl;
out << "Number of male students = " << countMale << endl;
out << "Average male GPA = " << avgMaleGPA << endl;
inFile.close();
outFile.close();
system ("pause");
return 0;
}