I currently want to input 2 text files and then output them to a text file that contains the summary of the students marks. One of the text file is called studentsDay and the other one is called studentsEvening. Both text files contains the student ID, given name, surname, score1, score2, score3, score4, score5. The studentsDay is look as follows:
The studentsEvening is look as follows: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
Now I want to output them to the file called report_regular.txt and it should contain student ID, surname, givenname, D/E, average score, grade and once the coding is done it should 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 done my code and it look like this:Code:s1012 Bennet, Anne D 56.20 P
s1236 Bridges, Tony D 82.20 D
s2341 Butcher, Michael D 60.80 P
s5454 Sunshine, Joe E 78.40 D
s5466 White, Vanessa E 70.00 Cr
s5553 Sunder, Jim E 67.20 Cr
Currently I can only output one student but not the other 5, I can only output the first evening student which is Joe Sunshine, I can output his student ID, his given name, surname, average score but I can't output his attendance mode and grade. Can somebody help me please.Code:#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
ifstream inFileDay;
ifstream inFileEvening;
ofstream outFile;
// delcare other variables
string studentdayId1;
string studenteveningId1;
string givenname, surname;
char attendancemode;
int score1, score2, score3, score4, score5;
double average;
string grade;
inFileDay.open("studentsDay.txt");
inFileEvening.open("studentsEvening.txt");
outFile.open("report_regular.txt");
outFile << fixed << showpoint;
outFile << setprecision(2);
inFileDay >> studentdayId1;
inFileEvening >> studenteveningId1;
outFile << studentdayId1;
outFile << studenteveningId1;
inFileDay >> surname;
inFileEvening >> surname;
inFileDay >> givenname;
inFileEvening >> givenname;
outFile << " " << givenname;
outFile << ", " << surname;
inFileDay >> attendancemode;
inFileEvening >> attendancemode;
outFile << " " << attendancemode;
inFileDay >> score1 >> score2 >> score3 >> score4 >> score5;
inFileEvening >> score1 >> score2 >> score3 >> score4 >> score5;
average = static_cast<double>(score1 + score2 + score3 + score4 + score5)/5.0;
outFile << " " << average << endl;
while(grade = average);
{
if ( grade >= 85 )
cout << "HD";
else
if ( grade >= 75 )
cout << "D";
else
if ( grade >= 65 )
cout << "Cr";
else
if ( grade >= 55 )
cout << "P";
else
cout << "F";
}
inFileDay.close();
inFileEvening.close();
outFile.close();
pause();
return EXIT_SUCCESS;
}