Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
// Function prototype
void getScore(int& score, ifstream& inFile);
void calcAverage(int, int, int, int, int);
int findLowest(int, int, int, int, int);
int grades(int, int, int, int, int);
int main()
{
ifstream inFile;
inFile.open("grades.txt");
int testScr1, testScr2, testScr3, testScr4, testScr5;
getScore(testScr1,inFile);
getScore(testScr2,inFile);
getScore(testScr3,inFile);
getScore(testScr4,inFile);
getScore(testScr5,inFile);
calcAverage(testScr1, testScr2, testScr3, testScr4, testScr5);
inFile.close();
return 0;
}
void getScore(int& score, ifstream& inFile)
{
inFile >> score;
}
void calcAverage(int s1, int s2, int s3, int s4, int s5)
{
int sum;
int lowest;
double average;
lowest = findLowest(s1, s2, s3, s4, s5);
sum = s1 + s2 + s3 + s4 + s5 - lowest;
average = sum / 4.0;
cout << setw(4) << fixed << showpoint << setprecision(2);
cout << "The avergae of the four highest scores are: " << average << endl;
}
int findLowest(int s1, int s2, int s3, int s4, int s5)
{
int lowest = s1;
cout << "The lowest test score is: " << lowest << endl;
return lowest;
}
this is the new code and it returns bogus numbers...what it should be reading is 2 digit grades and it does not or it returns something that I dont know how to fix