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

NEED WITHIN ONE HOUR OF POSTING C++ 1) Write a program that calculates the avera

ID: 3724782 • Letter: N

Question

NEED WITHIN ONE HOUR OF POSTING C++

1) Write a program that calculates the average of a group of five test scores, where the lowest score in the group is dropped. It should use the following functions:

int getScore() should ask the user for a test score, store it in a variable, and validate that it is not lower than 0 or higher than 100. This function should be called by the main once for each of the five scores to be entered.

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

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

Format the output in two columns and round off all real numbers to two decimal places.

When you run your program, your output should look like this one:

Enter a test score between 0 and 100: 98

Enter a test score between 0 and 100: 97

Enter a test score between 0 and 100: 95

Enter a test score between 0 and 100: 99

Enter a test score between 0 and 100: 91

The lowest grade (to be dropped):                        91.00

The total (after dropping the lowest grade): 389.00

The average (after dropping the lowest grade):       97.25

Explanation / Answer

#include <iomanip>
#include <iostream>
int getScore()
{
int num;
std::cout<<"Enter a test score between 0 and 100: ";
std::cin>>num;
return num;
}
int findLowest(int num1,int num2,int num3,int num4,int num5)
{
return num1<(num2<(num3<((num4<num5)?num4:num5)?num3:((num4<num5)?num4:num5))?num2:(num3<((num4<num5)?num4:num5)?num3:((num4<num5)?num4:num5)))?num1:(num2<(num3<((num4<num5)?num4:num5)?num3:((num4<num5)?num4:num5))?num2:(num3<((num4<num5)?num4:num5)?num3:((num4<num5)?num4:num5)));
}
void calcAverage(int num1,int num2,int num3,int num4,int num5)
{
int total = num1+num2+num3+num4+num5;
int lowest = (float)findLowest(num1,num2,num3,num4,num5);
std::cout<<"The lowest grade (to be dropped): "<<(float)lowest<<std::endl;
total = total - lowest;
std::cout<<"The total (after dropping the lowest grade): "<<(float)total<<std::endl;
std::cout<<"The average (after dropping the lowest grade): "<<(float)total/4.0<<std::endl;
}
int main()
{
int num1,num2,num3,num4,num5;
std::cout << std::fixed << std::showpoint;
std::cout << std::setprecision(2); //for setting decimal points to 2
while(1) //for checking the condition of marks
{
num1= getScore();
if(!(num1>100||num1<0))
break;
else
std::cout<<"Invalid Score !"<<std::endl;
}
while(1)
{
num2=getScore();
if(!(num2>100||num2<0))
break;
else
std::cout<<"Invalid Score !"<<std::endl;

}
while(1)
{
num3= getScore();
if(!(num3>100||num3<0))
break;
else
std::cout<<"Invalid Score !"<<std::endl;

}
while(1)
{
num4= getScore();
if(!(num4>100||num4<0))
break;
else
std::cout<<"Invalid Score !"<<std::endl;

}
while(1)
{
num5 = getScore();
if(!(num5>100||num5<0))
break;
else
std::cout<<"Invalid Score !"<<std::endl;

}
calcAverage(num1,num2,num3,num4,num5);
return 0;
}