# Thread: Help with Homework plz!

1. ## Help with Homework plz!

Hi new to the forums, thought you guys might be able to help me out, maybe not. I have a programming assignment as it follows:

1. Star Search (10 points) A particular talent competition is taking place on campus. This competition has 5 judges, each of whom awards a score between 0 and 10 to each contestant. Fractional scores, such as 7.4, are allowed. A contestant’s final score is determined by dropping the highest and lowest score received, then averaging the 3 remaining score. Allow the user to enter scores for as many contestants as wanted until the user indicates otherwise (do loop).

Write a C++ program called StarSearch that does the following. Note that I have given you the function header/signature for all of the functions you will be writing for this assignment. You may want to refer the example we did in class. Examples are posted on BlackBoard.

□ display the contestant number. This integer variable is incremented for each contestant.

□ implements a function
void getJudgeData(double &score)
that asks the user for a judge’s score, stores it in a reference parameter variable, and validates it. Input Validation: Do not accept judge scores lower than 0 or higher than 10. This function should be called by main once for each of the 5 judges. Hint: review Using Reference Variables as Parameters in your textbook in chapter 6 .

□ implements a function
void calcScore(double s1, double s2, double s3, double s4, double s5)
that calculates and displays the average of the 3 scores that remain after dropping the highest and lowest score the contestant received. It will call functions findLowest and findHighest to determine the lowest and highest scores. The function calcScore is called just once by main, and should be passed the 5 scores. The average score should be displayed to 2 decimal places.

□ implements a function
double findLowest(double s1, double s2, double s3, double s4, double s5)
that finds and returns the lowest of the 5 scores passed to it. This function is called by calcScore to determine which score to drop as the lowest.

□ implements a function
double findHighest (double s1, double s2, double s3, double s4, double s5)
that finds and returns the highest of the 5 scores passed to it. This function is called by calcScore to determine which score to drop as the highest.

I really am not sure what my if statement should look like when trying to knock off the highest and lowest score given...then to average the 3 remaining scores. any help at all would be awesome thanks!

2. Code:
```if (var < max && var > min)
{valid} else {invalid}```

3. One way to do it: Add all five numbers together then subtract whatever findHighest and findLowest return. That will give you the sum of the remaining three values, no if test required. You then only need to divide by three to get the average.

4. Try it first.