Answer:
The explanation and solution of this question is given below in explanation section. This program is written in c++ using dev C++. This below program run accurately according to requirement of the given question. While explanation of code is commented in the program.
Explanation:
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
double number[8];// user enter eight batting average
double average=0.0;// average of all 8 batting
for (int i=0; i<8; i++)// prompt user to enter batting average interactively
{
cout<<"Please enter batting average of "<<i<<"\n";
cin>>number[i]; // store batting average into array
}
double max = number[0];// maximum average variable declaration
for (int i = 0; i < 8; i++)//loop to find max average
{
if (max < number[i])
max = number[i];
}
double min = number[0];//minimum average variable declaration
for (int i = 0; i < 8; i++)//loop to find minimum average
{
if (min > number[i])
min = number[i];
}
cout << "The maximum batting average is : " << max<<"\n";//display maximum average
cout << "The minimum batting average is : " << min<<"\n";//display minimum average
for (int i=0; i<8; i++)//loop to calculate the average
{
average=average+number[i];// sum of all averages
}
average=average/8;//average of eight batting averages
cout<<"The average is "<<average<<"\n";//display the average
return o;
}