Hey, I'm trying to get my program to run correctly. I can get the black screen to come up after compiling, but it does not say "Press any key to continue...". I'm reading from input file and want to see results in an output file. My ultimate goal is to get it to run, so I can see the results in my outfile.. My code is here:
[LIST=1]
[*]#include <iostream>
[*]#include <fstream>
[*]#include <iomanip>
[*]using namespace std;
[*]void openFiles(ifstream& inData, ofstream& outData);
[*]void initialize(int& fcounter,int& mcounter,double& gpa,double& msum,double& fsum);
[*]void sumGrades(int fcounter,int mcounter,double gpa,double msum,double fsum,ifstream& inData,ofstream& outData);
[*]void averageGrade(int fcounter,int mcounter,double gpa,double msum,double fsum,double& femaleaverage,double& maleaverage);
[*]void printResults(ofstream& outData,int fcounter,int mcounter,double gpa,double msum,double fsum,double femaleaverage,double maleaverage);
[*]int main()
[*]{
[*]
[*] ifstream inData;
[*] ofstream outData;
[*]
[*] outData<<fixed<<showpoint;
[*] outData.precision(2);
[*]
[*] double gpa;
[*] int mcounter;
[*] int fcounter;
[*] double msum;
[*] double fsum;
[*] char gender;
[*] double femaleaverage;
[*] double maleaverage;
[*]
[*] openFiles(inData,outData);
[*] initialize(fcounter,mcounter,gpa,msum,fsum);
[*] outData<<"Processing grades.\n";
[*] sumGrades(fcounter,mcounter,gpa,msum,fsum,inData,outData);
[*] averageGrade(fcounter,mcounter,gpa,msum,fsum,femaleaverage,maleaverage);
[*] printResults(outData,fcounter,mcounter,gpa,msum,fsum,femaleaverage,maleaverage);
[*]
[*] inData>>gender>>gpa;
[*]
[*] inData.close();
[*] outData.close();
[*]
[*]
[*] system ("PAUSE");
[*] return 0;
[*]
[*]
[*]}
[*]
[*] void openFiles(ifstream& inData, ofstream& outData)
[*] {
[*] inData.open ("Project4.txt");
[*] outData.open ("Project4_output.txt");
[*] }
[*]
[*] void initialize(int& fcounter,int& mcounter,double& gpa,double& msum,double& fsum)
[*] {
[*]
[*] int malecounter = 0;
[*] int femalecounter = 0;
[*] double malesum = 0;
[*] double femalesum = 0;
[*] double gpa1 = 0;
[*] }
[*]
[*] void sumGrades(int fcounter,int mcounter,double gpa,double msum,double fsum,ifstream& inData,ofstream& outData)
[*]{
[*]
[*] char gender;
[*] while (inData)
[*] {
[*] switch (gender)
[*] {
[*]
[*] case 'm':
[*] msum += gpa;
[*] mcounter++;
[*] break;
[*]
[*] case 'f':
[*] fsum += gpa;
[*] fcounter++;
[*] break;
[*] }
[*] }
[*]}
[*] void averageGrade(int fcounter,int mcounter,double gpa,double msum,double fsum,double& femaleaverage,double& maleaverage)
[*] {
[*] femaleaverage = ( fsum / fcounter );
[*] maleaverage = ( msum / mcounter );
[*] }
[*]
[*] void printResults(ofstream& outData,int fcounter,int mcounter,double gpa,double msum,double fsum,double femaleaverage,double maleaverage)
[*] {
[*] outData<<"Sum female GPA = "<<fsum<<endl;
[*] outData<<"Sum male GPA = "<<msum<<endl;
[*] outData<<"Female count = "<<fcounter<<endl;
[*] outData<<"Male count = "<<mcounter<<endl;
[*] outData<<"Average female GPA = "<<femaleaverage<<endl;
[*] outData<<"Average male GPA = "<<maleaverage<<endl;
[*] }
[/LIST]