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;
}

First: you have defined printResult function with 6 parameters, why are you sending it 4 parameters when calling it in line 33??? (C++ compiler is telling you that!!!!)

Line 71, you are using MaleGPA in function sumGrades, although it's defined in initialize. (Do you know about Variable SCOPE?? if not, google "variables scope")

More and more of scoping problem in the rest of the code.

Line 96 you are defining outFile, but you use out to write to output stream.

Line 106, to use system, include stdlib.h library.

There are more and more errors. So, I advice you to go and read a little bit about variables, scopes, I/O operations and try to fix your program. I bet you will have no problem.

I have resolved a number of my errors and I know that I either have an extra { or } somewhere or put it the wrong way (or at least that's what I think) but I'm not sure where and was hoping maybe someone could look over it because I think I keep grazing over it. The errors I am getting are: line 36 a function definition is not allowed her before '{'
line 36 expected ',' or ';' before '{' token
line 55 a function definition is not allowed her before '{'
line 55 expected ',' or ';' before '{' token
line 63 a function definition is not allowed her before '{'
line 63 expected ',' or ';' before '{' token
line 108 expected '}' at end of input

#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, avgMaleGPA, avgFemGPA, 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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
{
     char ch;
     float gpa;
     OpenFiles(ch, gpa);
     float MaleGPA, FemGPA, avgMaleGPA, avgFemGPA;
     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, CountMale;
     sumGrades (countFemale, countMale, sumMaleGPA, sumFemGPA)
     avgFemGPA = FemGPA / countFem;
     avgMaleGPA = MaleGPA / countMale;
     }
     
     void printResults(int countFem, int countMale, float avgFemGPA, float avgMaleGPA)
     {
          ofstream outFile;
          outFile << "Number of female students = " << countFem << endl;
          outFile << "Average female GPA = " << avgFemGPA << endl;
          outFile << "Number of male students = " << countMale << endl;
          outFile << "Average male GPA = " << avgMaleGPA << endl;
}
inFile.close();
outFile.close();

system ("pause");

return 0;
}

You know you can't define a function within another function, don't you? If you properly format your code, the error will jump out at you immediately.

Yes, I do realize that I was having trouble finding where it was done.

one more thing, use proper indentation to make the code clearer and more readable. Wherever you start open a brace "{" you need one level of indentation.

commented: Isn't that what I just said? -3

I have fixed most of my errors. The only ones I am having now are:where it says inFile.close(); the error is "expected ',' or ';' before '.' token, expected constructor, destructor, or type conversion before '.' token" and then that also appears where outFile.close(); is. Where system ("pause"); is it states "expected constructor, destructor, or type conversion before '(' token, expected ',' or ';' before '(' token. Expected unqalified-id before "return", expected ',' or ';' before "retrun" and the final is expected declaration before '}' token

void printResults(int countFem, int countMale, float avgFemGPA, float avgMaleGPA)
     {
          ofstream outFile;
          outFile << "Number of female students = " << countFem << endl;
          outFile << "Average female GPA = " << avgFemGPA << endl;
          outFile << "Number of male students = " << countMale << endl;
          outFile << "Average male GPA = " << avgMaleGPA << endl;
     }
inFile.close();
outFile.close();
system ("pause");

return 0;
     }

You might want to post the entire code again. It's easier to tell you what went wrong in this case when you've posted all the properly formatted code

#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);
     averageGrades(avgFemGPA, avgMaleGPA);
     inFile >> ch >> gpa;    
     }
     
     printResult(countFemale, countMale, avgMaleGPA, avgFemGPA, 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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
     {
     char ch;
     float gpa;
     OpenFiles(ch, gpa);
     float MaleGPA, FemGPA, avgMaleGPA, avgFemGPA;
     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;
     }
     }
     void averageGrades(float avgFemGPA, float avgMaleGPA)
     {
     
     float FemGPA, MaleGPA;
     int countFem, countMale;
     float sumMaleGPA, sumFemGPA;
     sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
     avgFemGPA = FemGPA / countFem;
     avgMaleGPA = MaleGPA / countMale;
     }
     
     void printResults(int countFem, int countMale, float avgFemGPA, float avgMaleGPA)
     {
          ofstream outFile;
          outFile << "Number of female students = " << countFem << endl;
          outFile << "Average female GPA = " << avgFemGPA << endl;
          outFile << "Number of male students = " << countMale << endl;
          outFile << "Average male GPA = " << avgMaleGPA << endl;
}
inFile.close();
outFile.close();
system ("pause");

return 0;
}

You didn't bother to follow the link I posted, I can tell. If you can't follow simple formatting instructions, you won't be able to follow the complex code changes necessary to fix what you currently have.

Click on the link and learn, please:

You know you can't define a function within another function, don't you? If you properly format your code, the error will jump out at you immediately.

The only thing I can find at that link that hasn't been done in my program yet is the indentation of { and } and the separate indentations. I have read it twice and don't feel that it is such a huge issue that I have to fix that before the other errors as I am reformatting some of the things later anyways once I get it to fully compile

That's is the exact issue. Your code does not flow properly without proper indentation. It takes 10 minutes to do and you've wasted 7 hours by not doing it.

I know exactly what your problem is but without the formatting you can't see it and it's too complicated to explain.

Not all the formatting has been fixed yet but I am more worried about solving the errors and will worry about perfecting it later.

#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);
       averageGrades(avgFemGPA, avgMaleGPA);
       inFile >> ch >> gpa;    
    }
     
     printResult(countFemale, countMale, avgMaleGPA, avgFemGPA, 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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
                    {
                        char ch;
                        float gpa;
                        OpenFiles(ch, gpa);
                        float MaleGPA, FemGPA, avgMaleGPA, avgFemGPA;
                        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;
                         }
                    }
     void averageGrades(float avgFemGPA, float avgMaleGPA)
                              {
     
                                  float FemGPA, MaleGPA;
                                  int countFem, countMale;
                                  float sumMaleGPA, sumFemGPA;
                                  sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
                                  avgFemGPA = FemGPA / countFem;
                                  avgMaleGPA = MaleGPA / countMale;
                              }
     
     void printResults(int countFem, int countMale, float avgFemGPA, float avgMaleGPA)
                                  {
                                      ofstream outFile;
                                      outFile << "Number of female students = " << countFem << endl;
                                      outFile << "Average female GPA = " << avgFemGPA << endl;
                                      outFile << "Number of male students = " << countMale << endl;
                                      outFile << "Average male GPA = " << avgMaleGPA << endl;
                                  }
     inFile.close();
     outFile.close();
     system ("pause");

return 0;
}

And I would agree with the wasting time part had I spent the last 7 hours doing the program, only problem is I haven't been able to spend more than 5 min on it at a time. I have actually been spending about 30 seconds to do one thing at a time every 10 min or so as I work 50-60 hours a week and am in the middle of doing housework so I have been doing it one tiny modification at a time. And unfortunately still can't see where I am going wrong. I obviously know something is wrong I just am having trouble finding what. Maybe it's because I have looked at it for so long that I am overlooking it, I'm not sure.

I think I may have fixed some of the problem but need further guidance

#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);
       averageGrades(avgFemGPA, avgMaleGPA);
       inFile >> ch >> gpa;   
    }
     
     printResult(countFemale, countMale, avgMaleGPA, avgFemGPA, 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 countFem, int countMale, float sumMaleGPA, float sumFemGPA);
                    {
                        char ch;
                        float gpa;
                        OpenFiles(ch, gpa);
                        float MaleGPA, avgMaleGPA;
                        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;
                        }
                    }
     void averageGrades(float avgFemGPA, float avgMaleGPA);
                              {
     
                                  float FemGPA, MaleGPA;
                                  int countFem, countMale;
                                  float sumMaleGPA, sumFemGPA;
                                  sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
                                  avgFemGPA = FemGPA / countFem;
                                  avgMaleGPA = MaleGPA / countMale;
     
                              }
     
     void printResults(int countFem, int countMale, float avgFemGPA, float avgMaleGPA);
                                  {
                                      ofstream outFile;
                                      outFile << "Number of female students = " << countFem << endl;
                                      outFile << "Average female GPA = " << avgFemGPA << endl;
                                      outFile << "Number of male students = " << countMale << endl;
                                      outFile << "Average male GPA = " << avgMaleGPA << endl;
                                  }
     inFile.close();
     outFile.close();
     system ("pause");

return 0;
}

Here's the deal. I've been programming for over 30 years. Formatting is ultra important. I don't give a rats what you think about it. If you don't start formatting from the first line of code written to the last, you are not a programmer. Period.

I'm done here. You can't follow instructions, I can't help.

I agree with WaltP. Your code formatting has still some flaws. Come on, it's not that hard to fix that. Do it and we will help you out.

I fixed it long ago but wasn't going to bother with posting it if I wasn't getting help. I have fixed a lot with it but am still struggling to have it actually output to the output file and am struggling a bit with the concept of pass by reference.

#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 printResults(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);
averageGrades(avgFemGPA, avgMaleGPA);
inFile >> ch >> gpa;
}
cout << "Processing grades" << endl;
cout << "Output data is in file Ch7_Ex4Data.txt" << endl;

printResults(countFemale, countMale, avgMaleGPA, avgFemGPA, sumMaleGPA, sumFemGPA);
inFile.close();
outFile.close();
system ("pause");

return 0;
}

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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
{
char ch;
float gpa;
OpenFiles(ch, gpa);
float MaleGPA, avgMaleGPA, FemGPA, avgFemGPA;
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;
}
}

void averageGrades(float avgFemGPA, float avgMaleGPA)
{

float FemGPA, MaleGPA;
int countFem, countMale;
float sumMaleGPA, sumFemGPA;
sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
avgFemGPA = FemGPA / countFem;
avgMaleGPA = MaleGPA / countMale;

}

void printResults(int countFemale, int countMale, float avgMaleGPA, float avgFemGPA, float sumMaleGPA, float sumFemGPA)
{
ofstream outFile;
outFile << "Number of female students = " << countFemale << endl;
outFile << "Average female GPA = " << avgFemGPA << endl;
outFile << "Number of male students = " << countMale << endl;
outFile << "Average male GPA = " << avgMaleGPA << endl;
}

Oh and if this formatting isn't correct than I don't know what. I sat down with someone who is a programmer and they helped me with this. I had something else originally (besides what I posted here) and was told by this person who has been programming for 30+ years, what I had done was wrong and they helped me get to this.

Hold on, bucko! Not getting help? Let's recap:

You know you can't define a function within another function, don't you? If you properly format your code, the error will jump out at you immediately.

Yes, I do realize that I was having trouble finding where it was done. [formatting was hindering you]

one more thing, use proper indentation to make the code clearer and more readable. Wherever you start open a brace "{" you need one level of indentation.

The only thing I can find at that link that hasn't been done in my program yet is the indentation of { and } and the separate indentations. I have read it twice and don't feel that it is such a huge issue that I have to fix that before the other errors as I am reformatting some of the things later anyways once I get it to fully compile

Even thought group256 told you reformatting will help, and I told you reformatting will answer your question, you told us you know better. Then you got help from an obvious hack that completely screwed up all your formatting. He also helped you use questionable coding practices.

There's obviously nothing I at least can help you with. I can't read your code, and you refuse to make it readable.

Not sure how to quote here so I will just copy and paste
"Here's the deal. I've been programming for over 30 years. Formatting is ultra important. I don't give a rats what you think about it. If you don't start formatting from the first line of code written to the last, you are not a programmer. Period.

I'm done here. You can't follow instructions, I can't help." Mainly the I'm done here part. Unfortunately since no one else was helping I decided to go to someone who does programming on a daily basis and the help I got was something you consider questionable. Sorry you don't agree but I tried.

I'm sorry to tell you that the code that you posted, is no where near right!

First thing about formatting is indentation. There is no indentation in your code. Please take a look at some tutorials to properly indent your code, then post back here.

Group256 From my understanding of it I believe that this is the correct way on the indentation. Please correct me if I am wrong (I reformatted it).

#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 printResults(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);
        averageGrades(avgFemGPA, avgMaleGPA);
        inFile >> ch >> gpa;
    }
  cout << "Processing grades" << endl;
  cout << "Output data is in file Ch7_Ex4Data.txt" << endl;

printResults(countFemale, countMale, avgMaleGPA, avgFemGPA, sumMaleGPA, sumFemGPA);
inFile.close();
outFile.close();
system ("pause");

return 0;
}

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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
{
char ch;
float gpa;
OpenFiles(ch, gpa);
float MaleGPA, avgMaleGPA, FemGPA, avgFemGPA;
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;
    }
}

void averageGrades(float avgFemGPA, float avgMaleGPA)
{

float FemGPA, MaleGPA;
int countFem, countMale;
float sumMaleGPA, sumFemGPA;
sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
avgFemGPA = FemGPA / countFem;
avgMaleGPA = MaleGPA / countMale;

}

void printResults(int countFemale, int countMale, float avgMaleGPA, float avgFemGPA, float sumMaleGPA, float sumFemGPA)
{
ofstream outFile;
outFile << "Number of female students = " << countFemale << endl;
outFile << "Average female GPA = " << avgFemGPA << endl;
outFile << "Number of male students = " << countMale << endl;
outFile << "Average male GPA = " << avgMaleGPA << endl;
}

baconswife, I believe I mentioned previously, when you have a curly brace, you need one level of indentation, but you don't need indentation BEFORE it. So, let me point out some of your mistakes:

while(!inFile.eof())
    {
        sumGrades(countFemale, countMale, sumMaleGPA, sumFemGPA);
        averageGrades(avgFemGPA, avgMaleGPA);
        inFile >> ch >> gpa;
    }

should be changed to:

while(!inFile.eof())
{
    sumGrades(countFemale, countMale, sumMaleGPA, sumFemGPA);
    averageGrades(avgFemGPA, avgMaleGPA);
    inFile >> ch >> gpa;
}

as well as:

void initialize(int countFemale, int countMale, float sumFemGPA, float sumMaleGPA)
{
    float FemGPA = 0.0;
    float MaleGPA = 0.0;
    countFemale = 0;
    countMale = 0;
}

Please follow my patter for the rest of your code, post it here, then let's figure out your problem.

Let me point out that some programmers also like to put the '{' right after the statement. Say:

while(true) {
    //Do stuff here
}

Or some other only do the above-mentioned style just for loops and conditions.

I'm not trying to be a pain but I truly am confused. Per what I read (could have read it wrong) in the tutorial that was posted on this thread for the curly bracket "{" I have to indent it if it follows another curly bracket that hasn't had a closing bracket yet. Please guide me in the correct way to do it and why if I am wrong. For example

{Opening bracket one
stuff in between

    {Opening bracket two
        more stuff
    }Closing bracket for opening bracket two
} Closing bracket for opening bracket one

In general, it's said that we have 2 different type of formatting:
1- GNU
2- BSD

Look for prettyprint in wikipedia. Just read through, I guess the information in there is enough to being with.

So wasn't how I was doing it the GNU form?---
This code is from the prettyprint page on wikipedia

int
foo (int k)
{
  if (k < 1 || k > 2)
    {
      printf ("out of range\n");
      printf ("this function requires a value of 1 or 2\n");
    }
  else
    {
      printf ("Switching\n");
      switch (k)
	{
	case 1:
	  printf ("1\n");
	  break;
	case 2:
	  printf ("2\n");
	  break;
	}
    }
}

You forgot to indent your code after functions headers. Anyhow, let me re-point out that the reason formatting is important is because to make your code readable, cause it does not really matter to the machine how you write your code (Except you are coding in Python). Just try to work more on formatting. It's good to know, that in big projects that a lot of people work on different parts of the same program, anyone of them may have different formatting style and when they put their codes together, that would not look too good. Therefore we do have formatting tools in the industry. You can also use VIM editor and it will help you to do that easily.

Oh duh. That was dumb of me. Here is the modified code. Hope I didn't screw up this time.

#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 printResults(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);
        averageGrades(avgFemGPA, avgMaleGPA);
        inFile >> ch >> gpa;
    }
  cout << "Processing grades" << endl;
  cout << "Output data is in file Ch7_Ex4Data.txt" << endl;

printResults(countFemale, countMale, avgMaleGPA, avgFemGPA, sumMaleGPA, sumFemGPA);
inFile.close();
outFile.close();
system ("pause");

return 0;
}

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 countFem, int countMale, float sumMaleGPA, float sumFemGPA)
{
    char ch;
    float gpa;
    OpenFiles(ch, gpa);
    float MaleGPA, avgMaleGPA, FemGPA, avgFemGPA;
    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;
    }
}

void averageGrades(float avgFemGPA, float avgMaleGPA)
{

    float FemGPA, MaleGPA;
    int countFem, countMale;
    float sumMaleGPA, sumFemGPA;
    sumGrades (countFem, countMale, sumMaleGPA, sumFemGPA);
    avgFemGPA = FemGPA / countFem;
    avgMaleGPA = MaleGPA / countMale;

}

void printResults(int countFemale, int countMale, float avgMaleGPA, float avgFemGPA, float sumMaleGPA, float sumFemGPA)
{
    ofstream outFile;
    outFile << "Number of female students = " << countFemale << endl;
    outFile << "Average female GPA = " << avgFemGPA << endl;
    outFile << "Number of male students = " << countMale << endl;
    outFile << "Average male GPA = " << avgMaleGPA << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.