Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ : Write a program that calculates the average of a group of test scores, whe

ID: 3898501 • Letter: C

Question

C++ : Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It must have the following functions:

void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function must be called by main once for each of the six scores to be entered (so 6 times).

Validate the test scores entered are greater than or equal to 0 and less than or equal to 100.

void calcAverage() should calculate and display the average of the five highest scores. This function must be called just once by main, and must be passed the six scores.

int findLowest() should find and return the lowest of the lowest scores passed to it. It must be called by calcAverage, which uses the function to determine which of the six scores to drop.

Explanation / Answer

#include <iostream>

using namespace std;
void getScore(int *score){
while(1){
cout << "Enter the score: ";
cin >> *score;
if(*score >= 0 && *score <= 100)
break;
else
cout << "Invalid score ";
}
}
int findLowest(int scores[]){
int min = 101;
for(int i = 0; i < 6; i++)
if(min > scores[i])
min = scores[i];
return min;
}
void calcAverage(int scores[]){
int leastScore = findLowest(scores);
int sum = 0;
for(int i = 0; i < 6; i++)
sum += scores[i];
sum -= leastScore;
cout << "The total of highest 5 scores is " << sum / 6.0 <<endl;
}
int main()
{
int score;
int scores[6];
for(int i = 0; i < 6; i++){
getScore(&score);
scores[i] = score;
}
calcAverage(scores);
return 0;
}

**Comment for any further queries.