Problem Statement Write a program to calculate the execution score for the artis
ID: 3671712 • Letter: P
Question
Problem Statement Write a program to calculate the execution score for the artistic gymnastics. The execution score, determined by a six-judge Panel, begins at 10 and deductions are made for errors and faults in technique, execution and artistry/composition. Each judge independently determines his/her score. The highest and lowest scores are dropped, and the gymnast's Execution Score is the average of the remaining four judges' scores. For exam, the six judges gave the gymnast scores of 9.3, 9.2, 9.55, 9.4, 8.9 and 9.18 respective, the Execution Score for this gymnast is: (9.3+9.2+9.4+9.18)/4-9.27. The following list gives the requirements for your program As long as the user inputs six valid scores, your program should display the original sequence in the order the scores are typed, and also display the sequence of scores after dropping the lowest and highest scores, then display the final Execution Score for the gymnast. Your program should handle the case when the user doesn't input the valid score, such as a letter instead of a double-floating point number, or the score is not in the range [0.0, 10.0]. The user is allowed to try as many times as possible Define a function void remove (double scores, int& current size) that removes the lowest score and highest score from the array passed in as the first parameter. The order of the original scores is preserved. For example, if the original scores are: 9.3, 9.2, 9.55, 9.4, 8.9 and 9.18 After calling this function, the array should contain: 9.3, 9.2, 9.4 and 9.18 in this order Define a function double final score (double acores[, int current_ size) that calculate the final Execution Score for a gymnast after dropping his/her lowest and highest scores . The following are some examples of running your program: (note these samples cannot cover all the possible cases, and you should think about your own testing cases)Explanation / Answer
C++ code for finding the Final execution code for the gymnast
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <stdio.h>
using namespace std;
void remove (double score[], int current_size) // function to remove lowest and
//highest score
{
int i;
double min = 0.0; // consider the min and max to be 0.0
double max = 0.0;
int j=0,k=0;
for(i=0;i<6;i++)
{
if(score[i]>max) { max = score[i]; j=i;} // finding max and recording its index in j
else if(score[i]<min) { min = score[i]; k=i;} // finding min and recording its index in k
}
//printf("%d %d ", j,k );
score[j]=0.0;
score[k]=0.0; // making the highest and lowest score to 0 to minimize the effect
}
double final_score(double score[], int current_size)
{
int i;
double sum=0;
for(i=0;i<6;i++) sum = sum+score[i]; // function to calculate the final score
sum = sum/4;
return sum;
}
int main()
{
double score[6];
int i=0;
while(1)
{
printf("Please enter your score for the gymnast "); // this will test if the entered value
// is double or char
string s;
cin >> s; // if it is greater than 10 or less than 0 , it will
//print and error mesaage ,
char * p;
double d = strtod( s.c_str(), & p ); // similarly if it is char, it will print invalid
// input and ask for another input
if ( * p == 0 ) {
if(d>10 || d<0) printf("Score is not in the correct range ");
else {score[i]=d; i++;}
}
else { printf("invalid Score ");
}
if(i==6) break;
}
cout<< "the score from the 6 judges are ";
for(i=0;i<6;i++) cout << score[i]<< " ";
cout<< " ";
remove(score,6);
cout<< "score after dropping the lowest and highest scores are ";
for(i=0;i<6;i++) {if(score[i]!=0.0) cout << score[i]<< " ";}
cout<<" ";
double finalscore = final_score(score,4);
cout << "Final Execution Score is : "<< finalscore;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.