I am trying to write a program that will take the grades from an input file and average them and print them to an output file along with the names and grades.
I know i am missing something simple (but ive been staring at this for 6 hours). Here are my problems...
1. The grades are outputted correctly when i remove the last names from the input file but not when i leave them in. When left in the program outputs all 0 for grades and the same first name every time.
2. The last set of grades is repeated 5 times more than needed.
Code and input below.
using namespace std;
void CalculateAverage(ifstream& inp,ofstream& outp, double& courseAvg);
double classAvg = 0;
infile.open ("grades.txt"); // Open Input File
outfile.open ("grades_averages.txt"); // Open Output File
outfile<<fixed<<showpoint; // Show Decimal Point
outfile<<setprecision(2); // Set Two Decimals
outfile<<"Student Test1 Test2 Test3 Test4 Test5 Test6 Test7 Test8 Test9 Test10 Average "<<endl; //Header for Columns
infile.close(); // Close Input File
outfile.close(); // Close Output File
void CalculateAverage(ifstream& inp,ofstream& outp,double& courseAvg)
for( count=1; count<=10; count++)
inp >> score;
outp << left << left << setw(10)<< score;
sum = sum + score;