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

C++ Write a program named Lab5c.cpp according to the following story. A particul

ID: 3866139 • Letter: C

Question

C++

Write a program named Lab5c.cpp according to the following story.

A particular talent competition has seven judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the highest and lowest score received, then averaging the remaining scores.

Write a program that uses the method described above to calculate a contestant's score. It should include the following functions:

void getJudgeData(double &score);

The function getJudgeData should use the random number generator to determine the judge's score and return the score through the reference parameter. This function should be called by the main function once for each judge.

double calcScore(double judgeScores[ ], int count);

The function calcScore should calculate and return the average of the scores that remain after dropping the highest and lowest scores the performer received. Call findHighest and findLowest to determine the highest and lowest scores. This function should be called just once by the main, and should be passed the seven scores.

double findLowest(double judgeScores[ ], int count);

The function findLowest should find and return the lowest of the scores passed to it.

double findHighest(double judgeScores[ ], int count);

The function should find and return the highest of the scores passed to it.

Check. The function prototypes are written above the main function.

Check. A comment box is provided above each function header and includes the following information: name, description, parameters, and return.

In the main function,

Collect Judge Data For Contestant

Define a named constant for the number of judges. For example, const int NUM_JUDGES = 7;

Define an array of doubles named judgeScores to hold seven judge scores for a contestant.

Use a for loop to call the function getJudgeData seven times to get scores from the seven judges and store the judge data in the array.

Check. Whenever the number of judges is needed in the code, use the named constant.

Calculate Contestant Score

Define a double variable named contestantScore.

Call the function calcScore to calculate the contestant's score and save that in the variable.

Report Contestant Score

On the score board, display the scores from the seven judges and the final score for the contestant. It should look as follows.

Important note: do not prompt the user. The function getJudgeData( ) should use the random number generator to determine the judge's score.

You can use the random number generator to generate a whole number in a certain range. With a slight modification, you can easily generate a fractional number within a range.

Note. The functions, findLowest() and findHighest() should return double instead of int.

Explanation / Answer

Answer for the given Question:

See the below code for given problem statement

#include <iostream>

using namespace std;

// Function Prototypes

void getJudgeData(double &);

double calcScore(double, double, double, double, double, double, double);

int findHighest(double, double, double, double, double, double, double);

int findLowest(double, double, double, double, double, double, double);

int main()

{

double Score1, Score2, Score3, Score4, Score5, Score6, Score7;

// Call function getJudgeData once for each judge

getJudgeData(Score1);

getJudgeData(Score2);

getJudgeData(Score3);

getJudgeData(Score4);

getJudgeData(Score5);

getJudgeData(Score6);

getJudgeData(Score7);

// Call function calcScore passing to it the five scores

cout << calcScore(Score1, Score2, Score3, Score4, Score5, Score6, Score7);

cout << endl;

return 0;

}

void getJudgeData(double &Score)

{

do

{

cout << "Enter a judge’s score: ";

cin >> Score;

if (Score < 0 || Score > 10)

{

cout << " Error! Invalid score. "

<< "Judge's score must be greater than 0 and less than 10. ";

}

} while (Score < 0 || Score > 10);

}

double calcScore(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7)

{

int High, Low;

double Avg;

// Call function findHighest and findLowest passing 5 scores to them

High = findHighest(Score1, Score2, Score3, Score4, Score5, Score6, Score7);

Low = findLowest(Score1, Score2, Score3, Score4, Score5, Score6, Score7);

if (High == static_cast<int>(Score1))

{

if (Low == static_cast<int>(Score2))

Avg = (Score3 + Score4 + Score5+ Score6)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score2 + Score4 + Score5+ Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score3 + Score2 + Score5+Score6)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score2 + Score3 + Score6 + Score4)/3;

else

Avg = (Score2 + Score3 + Score5 + Score6)/3;

}

else if (High == static_cast<int>(Score2))

{

if (Low == static_cast<int>(Score1))

Avg = (Score3 + Score4 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score1 + Score4 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score3 + Score1 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score3 + Score1 + Score4 + Score6)/3;

else

Avg = (Score1 + Score3 + Score4 + Score5)/3;

}

else if (High == static_cast<int>(Score3))

{

if (Low == static_cast<int>(Score2))

Avg = (Score1 + Score4 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score1))

Avg = (Score2 + Score4 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score1 + Score2 + Score5+ Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score1 + Score2 + Score5+ Score6)/3;

else

Avg = (Score2 + Score1 + Score4 + Score3)/3;

}

else if (High == static_cast<int>(Score4))

{

if (Low == static_cast<int>(Score2))

Avg = (Score3 + Score1 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score2 + Score1 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score1))

Avg = (Score3 + Score2 + Score5 + Score6)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score3 + Score2 + Score5 + Score6)/3;

else

Avg = (Score2 + Score3 + Score1 + Score6)/3;

}

else if (High == static_cast<int>(Score6))

{

if (Low == static_cast<int>(Score2))

Avg = (Score3 + Score1 + Score5 + Score4)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score2 + Score1 + Score5 + Score4)/3;

else if (Low == static_cast<int>(Score1))

Avg = (Score3 + Score2 + Score5 + Score4)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score3 + Score2 + Score5 + Score1)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score3 + Score2 + Score1 + Score4)/3;

else

Avg = (Score2 + Score3 + Score1 + Score5)/3;

}

else if (High == static_cast<int>(Score7))

{

if (Low == static_cast<int>(Score2))

Avg = (Score3 + Score1 + Score5 + Score4 + Score2)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score2 + Score1 + Score5 + Score4 + Score6)/3;

else if (Low == static_cast<int>(Score1))

Avg = (Score3 + Score2 + Score5 + Score4 + Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score3 + Score2 + Score5 + Score1 + Score6)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score3 + Score2 + Score1 + Score4 + Score6)/3;

else

Avg = (Score2 + Score3 + Score1 + Score5 + Score4)/3;

}

else

{

if (Low == static_cast<int>(Score2))

Avg = (Score3 + Score4 + Score1 + Score6)/3;

else if (Low == static_cast<int>(Score3))

Avg = (Score2 + Score4 + Score1 + Score6)/3;

else if (Low == static_cast<int>(Score4))

Avg = (Score3 + Score2 + Score1 + Score6)/3;

else if (Low == static_cast<int>(Score5))

Avg = (Score3 + Score2 + Score1 + Score6)/3;

else

Avg = (Score2 + Score3 + Score4 + Score6)/3;

}

return Avg;

}

int findHighest(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7)

{

if (Score1 > Score2 && Score1 > Score3 && Score1 > Score4 && Score1 > Score5 && Score1 > Score6 && Score1 > Score7)

return Score1;

else if (Score2 > Score1 && Score2 > Score3 && Score2 > Score4 && Score2 > Score5 && Score2 > Score6 && Score2 > Score7)

return Score2;

else if (Score3 > Score2 && Score3 > Score1 && Score3 > Score4 && Score3 > Score5 && Score3 > Score6 && Score3 > Score7)

return Score3;

else if (Score4 > Score2 && Score4 > Score3 && Score4 > Score1 && Score4 > Score5 && Score4 > Score6 && Score4 > Score7)

return Score4;

else if (Score5 > Score1 && Score5 > Score2 && Score5 > Score3 && Score5 > Score4 && Score5 > Score6 && Score5 > Score7)

return Score4;

else if (Score6 > Score2 && Score6 > Score3 && Score6 > Score1 && Score6 > Score5 && Score6 > Score4 && Score6 > Score7)

return Score4;

else

return Score7;

}

int findLowest(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7)

{

if (Score1 < Score2 && Score1 < Score3 && Score1 < Score4 && Score1 < Score5 && Score1 < Score6 && Score1 < Score7)

return Score1;

else if (Score2 < Score1 && Score2 < Score3 && Score2 < Score4 && Score2 < Score5 && Score2 < Score6 && Score2 < Score7)

return Score2;

else if (Score3 < Score2 && Score3 < Score1 && Score3 < Score4 && Score3 < Score5 && Score3 < Score6 && Score3 < Score7)

return Score3;

else if (Score4 < Score2 && Score4 < Score3 && Score4 < Score1 && Score4 < Score5 && Score4 < Score6 && Score4 < Score7)

return Score4;

else if (Score5 < Score1 && Score5 < Score2 && Score5 < Score3 && Score5 < Score4 && Score5 < Score6 && Score5 < Score7)

return Score4;

else if (Score6 < Score2 && Score6 < Score3 && Score6 < Score1 && Score6 < Score5 && Score6 < Score4 && Score6 < Score7)

return Score4;

else

return Score7;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote