Answer:
See explaination
Step-by-step explanation:
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
void getJudgeData(double &score);
double calcScore(double scores[]);
int findLowest(double scores[]);
int findHighest(double scores[]);
int main() {
const int COL=5;
int row;
double score;
cout<<"How many students data you want to enter ? ";
cin>>row;
// Creating 2-D array Dynamically
double** scores = new double*[row];
for (int i = 0; i < row; ++i)
scores[i] = new double[COL];
for(int i=0;i<row;i++)
{
cout<<"\\Performer#"<<(i+1)<<":"<<endl;
for(int j=0;j<COL;j++)
{
cout<<"Enter Score given by judge#"<<(j+1)<<":";
getJudgeData(scores[i][j]);
}
}
for(int i=0;i<row;i++)
{
cout<<"Performer#"<<(i+1)<<" score :"<<calcScore(scores[i])<<endl;
}
return 0;
}
void getJudgeData(double &score)
{
while(true)
{
cin>>score;
if(score<0 || score>10)
{
cout<<"Invalid.Must be between 0-10"<<endl;
cout<<"re-enter :";
}
else
{
break;
}
}
}
double calcScore(double scores[])
{
double sum=0;
int min= findLowest(scores);
int max= findHighest(scores);
for(int i=0;i<5;i++)
{
if(i!=min && i!=max)
{
sum+=scores[i];
}
}
return sum/3;
}
int findLowest(double scores[])
{
double min=scores[0];
int minIndex=0;
for(int i=0;i<5;i++)
{
if(min>scores[i])
{
min=scores[i];
minIndex=i;
}
}
return minIndex;
}
int findHighest(double scores[])
{
double max=scores[0];
int maxIndex=0;
for(int i=0;i<5;i++)
{
if(max<scores[i])
{
max=scores[i];
maxIndex=i;
}
}
return maxIndex;
}