void calcScore(ofstream& fout, string name, double score1, double score2, double score3, double score4, double score5)
{
double lowest, highest;
highest = findHighest( score1, score2, score3, score4, score5);
lowest = findLowest(score1, score2, score3, score4, score5);
double totalScore = (score1 + score2 + score3 + score4 + score5)-(highest+lowest);
double avgScore = (totalScore)/3;
fout.open("results.dat");
fout << setprecision (3);
fout << name << " " << avgScore << endl;
fout.close();
}
[/code]
Basically, I need the name from the input file (which looks like this:)
1 2 3
|
2
Jennifer 10 9 8 9.5 10
Michael 10 9 10 9 10
|
and the average of the scores omitting the highest and lowest score. I have been getting it to output one of the names and averages with the code the way that it is, but am having no luck getting it to preform correctly.
What should I do in order to fix this file output problem? The data is reading into the program from a file just fine, but will not write out to a different one correctly.