Question
PLEASE CALL getMinMax in C. Thank you. /* ******************************************************* Determines the lowest and highest score for one performer PRE : scoresList[] - a list of
PLEASE CALL getMinMax in C. Thank you.
/* *******************************************************
Determines the lowest and highest score for one performer
PRE : scoresList[] - a list of 5 scores
POST : lowest, highest scores determined
and passed back to the caller as output parameters
*/
void getMinMax(const int scoreList[], int *min, int *max)
{
int j;
*min = *max = scoreList[0];
for (j = 1; j < NUM_JUDGES; j++)
{
if (scoreList[j] < *min)
*min = scoreList[j];
if (scoreList[j] > *max)
*max = scoreList[j];
}
}
/* *******************************************************
Calculates the final score for each performer:
average of 3 scores with lowest and highest eliminated
PRE : perfData - without the final score
POST : perfData - with the final score calculated
*/
void calculateScore(LIST *perfData)
{
int i, j;
int finalScore, lowest, highest;
for (i = 0; i < perfData->size; i++)
{
finalScore = 0;
for (j = 0; j < NUM_JUDGES; j++)
{
finalScore += perfData->list[i].scores[j];
}
// call getMinMax
perfData->list[i].final = finalScore - lowest - highest;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started