using namespace std;
double calcAverage (int first, int second, int third);
int findHighest (int first, int second, int third);
int findLowest (int first, int second, int third);
// This program reads data from a file.
int main()
{
ifstream inputFile;
string filename, name;
int first, second, third;
double class_average, average;
// Get the filename from the user.
cout << "Enter the filename: ";
cin >> filename;
// This function calculates and returns the average of the three scores passed as parameters.
double calcAverage (int first, int second, int third);
// This function determines and returns the highest of the three scores passed as parameters.
int findHighest (int first, int second, int third);
// This function determines and returns the lowest of the three scores passed as parameters.
int findLowest (int first, int second, int third);
inputFile.open("filename.c_str()");
if (!inputFile)
{
cout << "File open failure!" << endl;
}
else
{
while (inputFile >> name >> first >> second >> third)
{
cout << name << &calcAverage << &findHighest << &findLowest << endl;
}
//Calculates the average of each students' group of tests.
double calcAverage (int first, int second, int third, double average)
{
average = ((first + second + third) / 3);
return average;
}
//Finds the highest test score out of the 3.
int findHighest (int first, int second, int third)
{
if (first > second && first > third)
{
return first;
}
else if ( second > first && second > third)
{
return second;
}
else
{
return third;
}
}
//Finds the lowest test score out of the three.
int findLowest (int first, int second, int third)
{
if (first < second && first < third)
{
return first;
}
else if ( second < first && second < third)
{
return second;
}
else
{
return third;
}
return 0;
}