In this assignment you have to write a program for an instructor that has 5 exam scores during the semester. The exam score is between 0 and 100 inclusive. Fractional exam scores, such as 88.5, are allowed. A student's final average exam score is determined by dropping the highest and lowest exam score, then averaging the 3 remaining exam score is the final grade. Write a program that calculates the average exam score. It should include the following functions:
Function prototype | Description |
void getExam(double &) | Should ask the user for an exam score and store it in a reference parameter variable, and validate the score. This function should be called by main one for each of the 5 exam scores. It should check for exam escores between 0 and 100 inclusive. |
void calcAverage(double, double, double, double, double) | Should calculate and display the average of the 3 exam scores that remain after dropping the highest and lowest exam scores the student has received. This function should be called just once by main, and should be passed the 5 exam scores. |
double findLowest(double, double, double, double, double) | This function should find and return the lowest of the 5 exam scores passed to it. This function should be called by calcAverage, which uses the returned information to determine which of the lowest exam scores to drop. |
double findHighest(double, double, double, double, double) | This function should find and return the highest of the 5 exam scores passed to it. This function should be called by calcAverage, which uses the returned information to determine which of the highest exam scores to drop. |
Helpful hints for doing this assignment:
Program requirements and/or constraints:
Sample output:
Enter exam score between 0 and 100: 85
Enter exam score between 0 and 100: 90
Enter exam score between 0 and 100: 78
Enter exam score between 0 and 100: 82
Enter exam score between 0 and 100: 70
The student's average exam score is 81.67
Do you want to enter the exam for another student?
Enter y or n: y
Enter exam score between 0 and 100: 120
Exam score must be in the range 0-100. Please re-enter exam score: 76
Enter exam score between 0 and 100: 76
Enter exam score between 0 and 100: 76
Enter exam score between 0 and 100: 76
Enter exam score between 0 and 100: 76
The student's average exam score is 76.00
Do you want to enter the exam for another student?
Enter y or n: y
Enter exam score between 0 and 100: -10
Exam score must be in the range 0 - 100. Please re-enter exam score: 100
Enter exam score between 0 and 100: 0
Enter exam score between 0 and 100: 80
Enter exam score between 0 and 100: 90
Enter exam score between 0 and 100: 70
The student's average exam score is 80.00
Do you want to enter the exam for another student?
Enter y or n: y
Enter exam score between 0 and 100: 87
Enter exam score between 0 and 100: 89
Enter exam score between 0 and 100: 82
Enter exam score between 0 and 100: 92
Enter exam score between 0 and 100: 76
The student's average exam score is 86.00
Do you want to enter the exam for another student?
Enter y or n: n