Gpa.cpp

Here is what I have so far. However, I can get the program to compile but without the right output. Can anyone point me in the right direction?



Make a program so that the function main is merely a collection of function calls. Your program should use the following functions.
a. Function openFiles: This function opens the input and out files, and sets the output of the floating point numbers to two decimal places in a fixed decimal format with a decimal point and trailing zeros.
b. Function initialize: This function initializes variables such as countFemale, countMale, sumFemaleGPA, and sumMaleGPA.
c. Function sumGrades: This function finds the sum of female and male students GPA
d. Function averageGrade: This function finds the average GPA for female and male students
e. Function printResults: This function outputs the relevant results


#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

void openFiles();
void averageGpa();
void initialize();
void sumGrades();
void printResult(ofstream& outp, char gender, double avg);


int main()
{
int numMale=0;
int numFemale=0;
double averageFemale= 0.00;
double averageMale = 0.00;
double gpa = 0.00;
double sumGpaFemale = 0.00;
double sumGpaMale = 0.00;


openFiles();
ifstream infile;
ofstream outfile;

cout << "Processing grades " << endl;
cout << "Gpainfile.txt " << endl;
cout << " " << endl;
system("pause");
return 0;
}
void openFiles()
{
int numMale=0;
int numFemale=0;
double averageFemale= 0.00;
double averageMale = 0.00;
double gpa = 0.00;
double sumGpaFemale = 0.00;
double sumGpaMale = 0.00;
char gender;
ifstream infile;
ofstream outfile;

infile.open ("c:\\Gpainfile.txt");
if (!infile)
{
cout << "InFile not found" << endl;
cout << "Program cannot execute." << endl;

}



outfile.open ("c:\\Gpainfile.txt");


outfile << setprecision(2);

infile >> gender >> gpa;
while (infile >> gender >> gpa)

{
outfile << gender << " " << gpa << endl;

}

}
for the function, openFiles(), might I suggest that your variable, gender, be of type string instead of type char??
Topic archived. No new replies allowed.