I want to calculate the actual average score from these two input test files, one is called StudentsDay.txt and the other one is called StudentsEvening.txt
StudentsDay.txt look like this:
Code:
s1012 Anne Bennet       45 77 62 18 79
s1236 Tony Bridges       81 83 89 95 63
s2341 Michael Butcher   72 83 48 26 75
StudentsEvening.txt look like this:
Code:
s5454 Joe Sunshine      66 89 78 74 85
s5466 Vanessa White   62 77 44 88 79
s5553 Jim Sunder         66 74 48 53 95
I have already got their individual average score from each of the student and now I only want to get the actual average from the 6 students average score. So this is what I meant:
Code:
Anne Bennet average is 56.20
Tony Bridges average is 82.20
Michael Butcher average is 60.80
Joe Sunshine average is 78.40
Vanessa While average is 70.00
Jim Sunder average is 67.20
The average of 6 students is 69.13
Here's the code:
Code:
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
    ifstream inFileDay;
    ifstream inFileEvening;
    ofstream outFile;

    string studentdayId;
    string studenteveningId;
    string givenname, surname;
    int score1, score2, score3, score4, score5;
    int studentcounter;
    double AverageDay, AverageEvening;
    string grade;
    
    float maxscore;
    float minscore;
    float allaverage;
    char maxTime='D';
    char minTime='D';
    string maxGrade;
    string minGrade;
    string maxSID;
    string minSID;
    string maxName;
    string minName;

    maxscore=-1;
    minscore=101;

    inFileDay.open("studentsDay.txt");
    inFileEvening.open("studentsEvening.txt");
    outFile.open("report_regular.txt",std::ios::trunc);

    outFile.setf(ios::fixed, ios::floatfield);
    outFile.setf(ios::showpoint);
    outFile<<setprecision(2);

    outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl;

    while (!inFileDay.eof() )
    {
        inFileDay>>studentdayId;
        outFile<<studentdayId<<"  ";
        inFileDay>>givenname>>surname;
        outFile<<surname<<", ";
        outFile<<givenname<<" ";
        outFile<<"D ";

        inFileDay>>score1>>score2>>score3>>score4>>score5;

        AverageDay=static_cast<double>(score1+score2+score3+score4+score5)/5.0;

        outFile<<AverageDay<<"  ";
        outFile.setf(ios::right);

        if(AverageDay>=85 && AverageDay<=100)
            grade="HD";
        else if(AverageDay>=75 && AverageDay<=85)
            grade="D ";
        else if(AverageDay>=65 && AverageDay<=75)
            grade="Cr";
        else if(AverageDay>=55 && AverageDay<=65)
            grade="P ";
        else
            grade="F ";
            
        outFile<<grade<<endl;
            
        if(maxscore<AverageDay)
        {
            maxscore=AverageDay;
            maxSID=studentdayId;
            maxName=givenname+" "+surname;
            maxGrade=grade;
        }
        if(minscore>AverageDay)
        {
            minscore=AverageDay;
            minSID=studentdayId;
            minName=givenname+" "+surname;
            minGrade=grade;
        }

        studentcounter++;
    }

    while (!inFileEvening.eof() )
    {
        inFileEvening>>studenteveningId;
        outFile<<studenteveningId<<"  ";
        inFileEvening>>givenname>>surname;
        outFile<<surname<<", ";
        outFile<<givenname<<" ";
        outFile<<"E ";
        inFileEvening>>score1>>score2>>score3>>score4>>score5;

        AverageEvening=static_cast<double>(score1+score2+score3+score4+score5)/5.0;
        
        outFile<<setw(2)<<AverageEvening<<" ";
        outFile.setf(ios::right);

        if(AverageEvening>=85 && AverageEvening<=100)
            grade="HD";
        else if(AverageEvening>=75 && AverageEvening<=85)
            grade="D ";
        else if(AverageEvening>=65 && AverageEvening<=75)
            grade="Cr";
        else if(AverageEvening>=55 && AverageEvening<=65)
            grade="P ";
        else
            grade="F ";
            
        outFile<<grade<<endl;
            
        if(maxscore<AverageEvening)
        {
            maxscore=AverageEvening;
            maxSID=studentdayId;
            maxName=givenname+" "+surname;
            maxGrade=grade;
            maxTime='E';
        }
        if(minscore>AverageEvening)
        {
            minscore=AverageEvening;
            minSID=studentdayId;
            minName=givenname+" "+surname;
            minGrade=grade;
            minTime='E';
        }

        studentcounter++;
        allaverage = (AverageDay++ + AverageEvening++)/6;
    }
    
    
    
     
    outFile<<"\n+++++Section 2 The Maximum+++++\n\n"
        <<maxName<<" ("<<maxSID<<", "<<maxTime<<") is my best student, with "
        <<"a score of "<<maxscore<<" ("<<maxGrade<<")\n"<<minName<<" ("<<minSID
        <<", "<<minTime<<"), you need to drop this class... you only got a "
        <<minscore<<" ("<<minGrade<<')'<<std::flush;
    outFile<<"The average of 6 students is" << allaverage << endl;
    return 0;
}
The purple text is the part I try to get the actual results from the 6 students average but I still could not get it. How should it be done?