Question

In: Computer Science

Programming Challenge #10. C++ Early Objects 10ed. A talent competition has five judges, each of whom...

Programming Challenge #10. C++ Early Objects 10ed.

A 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

#include <iostream>
#include <iomanip>
using namespace std;

// Function prototypes
double getJudgeData();  
double calcScore(double, double, double, double, double);                       
double findLowest(double, double, double, double, double);                      
double findHighest(double, double, double, double, double);
                
int main()
{
        double score1, score2, score3, score4, score5,   // 5 judge's scores
          finalScore;
   
        // Inform the user what the program does
        cout << "After you enter 5 judge scores for this contestant, \n"
        << "this program will drop the highest and lowest score \n"
        << "and then average the remaining three scores.\n\n";
        

        return 0;
}// end of main function


the three remaining scores. Write a program that uses these rules to calculate and display a contestant's score.

Solutions

Expert Solution

#include <iostream>
#include <iomanip>
using namespace std;

// Function prototypes
double getJudgeData();
double calcScore(double, double, double, double, double);
double findLowest(double, double, double, double, double);
double findHighest(double, double, double, double, double);
int main()
{ //variables to store score
   double score1;
   double score2;
   double score3;
   double score4;
double score5;
cout << "After you enter 5 judge scores for this contestant, \n"
<< "this program will drop the highest and lowest score \n"
<< "and then average the remaining three scores.\n\n";
// get score
   score1=getJudgeData();
   score2=getJudgeData();
   score3=getJudgeData();
   score4=getJudgeData();
   score5=getJudgeData();
   //get highest lowest and average
double lowest = findLowest(score1, score2, score3, score4, score5);
double highest = findHighest(score1, score2, score3, score4, score5);
   double average=   calcScore(score1, score2, score3, score4, score5); //dropping highest lowest

cout << "Highest Score: " << highest<<endl;
cout << "Lowest Score: " << lowest<<endl;
cout<<"Excluding highest and lowest scores, the average score was "<< average<< endl;

   return 0;
}
double getJudgeData(){
double score;
cout<<"Enter a judge's score: ";
cin>> score;
while(score<0||score>10)
{cout<<"Score must be between 0.0 and 10.0: " << endl;
cout<<"Re-Enter a judge's score: "<< endl;
cin>>score;
}
return score;
}
double calcScore (double score1, double score2, double score3, double score4, double score5){
double sum;
double average;
double lowest = findLowest(score1, score2, score3, score4, score5);
double highest = findHighest(score1, score2, score3, score4, score5);
sum = score1 + score2 + score3 + score4 + score5; //add all
sum = sum - (highest); //subtract highest
sum = sum - (lowest); //subtract lowest
average = double (sum / 3 ); //find average
return average;
}
double findLowest(double score1, double score2, double score3, double score4, double score5){
int arr [5];
arr[0]= score1;
arr[1]= score2;
arr[2]= score3;
arr[3]= score4;
arr[4]= score5;
double lowest = arr[0]; //assume first is lowest
for(int i = 0; i < 5; i++){
if(arr[i] < lowest){ //update if another lowest comes
lowest = arr[i];
}
}
return lowest; //return the lowest at the end
}
double findHighest(double score1, double score2, double score3, double score4, double score5){
int arr [5];
arr[0]= score1;
arr[1]= score2;
arr[2]= score3;
arr[3]= score4;
arr[4]= score5;
double highest = arr[0]; //assume first is highest
for(int i = 0; i < 5; i++){
if(arr[i] > highest){ // update if any other comes highest
highest = arr[i];
}
}
return highest; //return the new highesr
}

OUTPUT:

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW
PLEASE GIVE A THUMBS UP


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...
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...
Homework 3 – Programming with C++ What This Assignment Is About: • Classes and Objects •...
Homework 3 – Programming with C++ What This Assignment Is About: • Classes and Objects • Methods • Arrays of Primitive Values • Arrays of Objects • Recursion • for and if Statements • Insertion Sort 2. Use the following Guidelines • Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). • User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for...
java from control structures through objects 6th edition, programming challenge 5 on chapter 16 Write a...
java from control structures through objects 6th edition, programming challenge 5 on chapter 16 Write a boolean method that uses recursion to determine whether a string argument is a palindrome. the method should return true if the argument reads the same forward amd backword. Demonstrate the method in a program, use comments in the code for better understanding. there must be a demo class and method class also .. generate javadocs through eclipse compiler. And make a UML diagram with...
Explain what classes and objects are in object - oriented programming. Give an example of each...
Explain what classes and objects are in object - oriented programming. Give an example of each and explain how they work together in a computer program.
Three solid objects (A, B, and C) are placed in water. The objects each have constant...
Three solid objects (A, B, and C) are placed in water. The objects each have constant densities of 160, 260, and 745 kg/m3, respectively. a.) How do you immediately know all three objects will float? b.) Find the fraction of the volume submerged for each object. A: B: C: c.) If object C has the dimensions (length=8 m, width=7 m, height=3 m), how far does this object stick out of the water when floating (in this orientation)? m
MLS Company has five employees, each of whom earns $1,600 per month and is paid on the last day of each month.
MLS Company has five employees, each of whom earns $1,600 per month and is paid on the last day of each month. All five have been employed continuously at this amount since January 1. On June 1, the following accounts and balances exist in its general ledger: a. FICA—Social Security Taxes Payable, $992; FICA—Medicare Taxes Payable, $232. (The balances of these accounts represent total liabilities for both the employer’s and employees’ FICA taxes for the May payroll only.) b. Employees’...
Merger Co. has 10 employees, each of whom earns $2,200 per month and has been employed...
Merger Co. has 10 employees, each of whom earns $2,200 per month and has been employed since January 1. FICA Social Security taxes are 6.2% of the first $117,000 paid to each employee, and FICA Medicare taxes are 1.45% of gross pay. FUTA taxes are 0.6% and SUTA taxes are 5.4% of the first $7,000 paid to each employee.
Make in c++ this Programming Challenge 1. Design your own linked list class to hold a...
Make in c++ this Programming Challenge 1. Design your own linked list class to hold a series of integers. The class should have member functions for appending, inserting, and deleting nodes. Don’t forget to add a destructor that destroys the list. Demonstrate the class with a driver program. 2. List Print Modify the linked list class you created in Programming Challenge 1 to add a print member function. The function should display all the values in the linked list. Test...
I am building a game in C programming language where I need to add objects of...
I am building a game in C programming language where I need to add objects of various length into a game board. The game board is 8X8 and we must account for the boundaries for the board and not go over them with our objects. The boards upper left corner is at 0x0 and we must return 1 if it fits and -1 if it does not fit. I have the following 2 functions to start with: ```int add_object_vert(int r,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT