Question

In: Computer Science

using C++ 8. Star Search A particular talent competition has 5 judges, each of whom awards...

using C++

8. Star Search
A particular talent competition has 5 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 3
remaining scores. Write a program that uses these rules to calculate and display a
contestant’s score. It should include the following functions:
• void getJudgeData() should ask the user for a judge’s score, store it in a reference
parameter variable, and validate it. If the user does not enter valid value, keep displaying error message shown in test cases until the user types in the valid value. This function should be called by main once for each
of the 5 judges.
• double calcScore() should calculate and return the average of the 3 scores that
remain after dropping the highest and lowest scores the performer received. This
function should be called just once by main and should be passed the 5 scores.
Two additional functions, described below, should be called by calcScore, which uses the
returned information to determine which of the scores to drop.
• double findLowest() should find and return the lowest of the 5 scores passed to it.
• double findHighest() should find and return the highest of the 5 scores passed to it.

test case

Judge #1 - Please enter a score between 0.0 and 10.0 : 5

Judge #2 - Please enter a score between 0.0 and 10.0 : 6.5

Judge #3 - Please enter a score between 0.0 and 10.0 : 9.5

Judge #4 - Please enter a score between 0.0 and 10.0 : 5.5

Judge #5 - Please enter a score between 0.0 and 10.0 : 6

Final Score : 6

Solutions

Expert Solution

Thanks for the question.
Here is the completed code for this problem.

Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution,

please rate the answer. Thanks


===========================================================================

#include<iostream>
using namespace std;

//void getJudgeData() should ask the user for a judge’s score,
// store it in a reference parameter variable, and validate it.
void getJudgeData(double &judge){
  
   do{
  
   cout<<"Please enter a score between 0.0 and 10.0: ";
   cin>>judge;
   if(judge<0.0 || judge>10.0)cout<<"Error: Enter score between 0.0 and 10.0 only.\n";
   }while(judge<0.0 || judge>10.0);

}
//double findLowest() should find and return the lowest of the 5 scores passed to it.
double findLowest(double j1, double j2 ,double j3, double j4, double j5){
  
   if(j1<=j2 && j1<=j3 && j1<=j4 && j1<=j5)return j1;
   if(j2<=j1 && j2<=j3 && j2<=j4 && j2<=j5)return j2;
   if(j3<=j1 && j3<=j2 && j3<=j4 && j3<=j5)return j3;
   if(j4<=j1 && j4<=j3 && j4<=j2 && j4<=j5)return j4;
   if(j5<=j1 && j5<=j3 && j5<=j4 && j5<=j2)return j5;
}
//double findHighest() should find and return the highest of the 5 scores passed to it.
double findHighest(double j1, double j2 ,double j3, double j4, double j5){
   if(j1>=j2 && j1>=j3 && j1>=j4 && j1>=j5)return j1;
   if(j2>=j1 && j2>=j3 && j2>=j4 && j2>=j5)return j2;
   if(j3>=j1 && j3>=j2 && j3>=j4 && j3>=j5)return j3;
   if(j4>=j1 && j4>=j3 && j4>=j2 && j4>=j5)return j4;
   if(j5>=j1 && j5>=j3 && j5>=j4 && j5>=j2)return j5;
}


double calcScore(double j1, double j2 ,double j3, double j4, double j5){
  
   double total=j1+j2+j3+j4+j5;
   double lowest = findLowest(j1,j2,j3,j4,j5);
   double highest = findHighest(j1,j2,j3,j4,j5);
  
   return (total-lowest-highest)/3.0;
}

int main(){
  
   double judge_1, judge_2, judge_3, judge_4, judge_5;
  
   cout<<"Judge #1 - ";getJudgeData(judge_1);
   cout<<"Judge #2 - ";getJudgeData(judge_2);
   cout<<"Judge #3 - ";getJudgeData(judge_3);
   cout<<"Judge #4 - ";getJudgeData(judge_4);
   cout<<"Judge #5 - ";getJudgeData(judge_5);
  
   //calculate and display acontestant’s score
   double final_score = calcScore(judge_1, judge_2, judge_3, judge_4, judge_5);
  
   cout<<endl
       <<"Final Score - "<<final_score<<endl;
}

===========================================================


Related Solutions

Instructions A particular talent competition has five judges, each of whom awards a score between 0...
Instructions A particular talent competition has five 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 three remaining scores. Write a program in Python that uses this method to calculate a contestant’s score. It should include the following functions: getJudgeData( ) should ask the user for a judge’s score, and validate...
For a particular DRAM design the cell capacitance is C,=50fF, Vpp=5 V and V=1.4 V. Each...
For a particular DRAM design the cell capacitance is C,=50fF, Vpp=5 V and V=1.4 V. Each cell represents a capacitive load on the bit line of 2fF. The sense amplifier and other circuitry attached to the bit line has a 20fF. What is the maximum number of cells that can be attached to a bit line while ensuring a minimum bit line signal of 0.1 V? How many bits of row addressing can be used? If the sense amplifier gain...
In a connection using 5/8-inch Φ (UNF-18, SAE Grade 8) bolts, each bolt is subjected to...
In a connection using 5/8-inch Φ (UNF-18, SAE Grade 8) bolts, each bolt is subjected to a varying axial load between 10 Kips to 20 Kips. Bolts can be preloaded between 0% (none) and 100%, at 10% intervals, of their proof strength. What range of preload is ideal so that the fatigue life of this joint is infinite without join separation? Use Modified Goodman Criteria for fatigue and show calculations for the preload levels between 0% and 100% (or at...
Problem5: (5 pts) using c programming Given an array of integers named “simple” of length 8...
Problem5: (5 pts) using c programming Given an array of integers named “simple” of length 8 and filled as follows: 5 20 13 8 0 16 55 2 int x = 5; int *p = &simple[3] ; Write the values of x after each of the following executes (write unknown if cannot be determined): (hint: pointer moves to new location after each line) x = *(p++);                                                   x = ___8_______________ p->simple[4]            x = *( p + 1) ;                                               x = _____16______________...
A doctor's office has 8 openings each day. If only 5 people are scheduled with the...
A doctor's office has 8 openings each day. If only 5 people are scheduled with the doctor today: a) How many ways can the 5 appointments be arranged in the available times? b) why did you choose the strategy you did c) this doctor prefers to sleep in. How many ways can the appointments be arranged with the first two morning openings left empty? d) what is the probability of the first twi appointment slots being left empty by chance...
An SAT test has 8 questions, each question having 5 multiple choice answers. If a student...
An SAT test has 8 questions, each question having 5 multiple choice answers. If a student make random guesses for each answer, find the probability that: a)the number of correct answers is 7. b)the number of correct answers is at least 4. c)the number of correct answers is fewer than 3.
C&A makes two types of products using four machines from 9 a.m. to 5 p.m. each...
C&A makes two types of products using four machines from 9 a.m. to 5 p.m. each day. Product A visits machines 1, 2, and 4. Product B only visits machines 1 and 3. The capacity is 0.4 unit per minute at machine 1, 0.12 unit per minute at machine 2, 0.2 unit per minute at machine 3, and 0.3 unit per minute at machine 4. The demand per day is 40 units for Product A and 160 units for Product...
Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each...
Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each of these: hold the names of the people running in the election hold the names of the subdivision hold the vote counts in the Brampton subdivision for each candidate hold the vote counts in the Pickering subdivision for each candidate hold the vote counts in the Markham subdivision for each candidate Use the data from the example below. Your C program should take the...
Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each...
Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each of these: hold the names of the people running in the election hold the names of the subdivision hold the vote counts in the Brampton subdivision for each candidate hold the vote counts in the Pickering subdivision for each candidate hold the vote counts in the Markham subdivision for each candidate Use the data from the example below. * Your C program should take...
Using c++ to find all the peaks elements in a 2d array, each element has eight...
Using c++ to find all the peaks elements in a 2d array, each element has eight neighbours
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT