I am trying to write a program that gets data from this text file:

Then, based on this data, the program is supposed to calculate the average gpa of each gender (f=female, m=male) and output the results in a new file.
It must also contain these five functions:
openFiles: this function opens the input and output files and sets the output of floating-point numbers to two decimal places in a fixed decimal format with a decimal point and trailing zeros.
initialize: this function initializes variables.
sumGrades: This function finds the sum of the female and male students GPAs.
average grade: This function finds the average GPA for male and female students.
printResults: this function outputs the relevent results.
I think I've done pretty good coding up the functions and all but since this is my first program using fstream im not sure how i need to implement them in my main function.
Here is what i have so far:
header:
#ifndef header_h
#define header_h
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <cstdlib>
using namespace std;
void extern initialize(int&, int&, float&, float&);
void extern openFiles(ifstream, ofstream);
void extern sumGrades(ifstream, ofstream, char, float, int&, int&, float&, float&);
void averageGrade (float&, float&, float, int, float, int);
void extern printResults (float, float, ofstream);
#endif
main:
#include "header.h"
int main()
{
char gender;
float gpa, sumFemaleGPA, sumMaleGPA;
ifstream inData;
ofstream outData;
int countFemale, countMale;
inData.open("./Ch7_Ex4Data.txt");
outData.open("./Ch7_Ex4Dataout.txt");
do
inData >> gender >> gpa;
while(!inData.eof());
inData.close();
outData.close();
system("PAUSE");
return EXIT_SUCCESS;
}
openFiles:
#include "header.h"
void openFiles(ifstream inData, ofstream outData)
{
inData.open("./Ch7_Ex4Data.txt");
outData.open("./Ch7_Ex4Dataout.txt");
outData << fixed << showpoint << setprecision(2);
inData.close();
outData.close();
}
sumGrades:
#include "header.h"
void sumGrades(ifstream inData, ofstream outData, char gender, float gpa, int& countFemale, int& countMale, float& sumFemaleGPA,
float& sumMaleGPA)
{
char m, f;
do
{
inData >> gender >> gpa;
if(gender == m)
{
sumMaleGPA += gpa;
countMale++;
}
else if (gender == f)
{
sumFemaleGPA += gpa;
countFemale++;
}
}
while(!inData.eof());
}
averageGrade:
#include "header.h"
void averageGrade (float& maleGrade, float& femaleGrade, float sumMaleGPA, int countMale, float sumFemaleGPA, int countFemale)
{
maleGrade = sumMaleGPA / static_cast<float>(countMale);
femaleGrade = sumFemaleGPA / static_cast<float>(countFemale);
}
printResults:
#include "header.h"
void
{
outData << "average male GPA: " << maleGrade << endl;
outData << "average female GPA: " << femaleGrade << endl;
}
averageGrade. - Alexandre C.