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

Can someone fix the problem plz with the average final score and the worst final

ID: 3567129 • Letter: C

Question

Can someone fix the problem plz with the average final score and
the worst final score, you can see it at the end in the results.ty

#include<stdio.h>
#include<float.h>

int main()
{
   float score;
   float sumScores;
   float highScore = FLT_MIN;
   float bestFinalScore = FLT_MIN;
   float lowScore = FLT_MAX;
   float worstFinalScore = FLT_MAX;
   int numJudge;
   float finalScore;
   char answer;
   int nbTot =0;
   float sumFinScores ;
  
   do{ nbTot++;
   sumScores = 0;
    for (numJudge=1; numJudge<=9; numJudge++)
   {
   printf("Enter the score of judge number %d : ",numJudge);
   fflush(stdin);
   scanf("%f", &score );

   sumScores += score;
   if(score > highScore)
   highScore = score;
   if(score < lowScore)
   lowScore = score;
  
   finalScore = ( sumScores - highScore - lowScore ) / 7 ;
  
   sumFinScores += finalScore;
  
   if(finalScore < worstFinalScore)
   worstFinalScore = finalScore;
   if(finalScore > bestFinalScore)
   bestFinalScore = finalScore;
}
   printf(" The final score of the skater is %4.2f ", finalScore);
     
   printf(" Do you want to continue ? (y/n) ");
   fflush(stdin);
   scanf("%c", &answer);
} while(answer == 'y');
  
printf("The total number of skaters : %d ", nbTot);
  
printf(" The average final score is %4.2f ", sumFinScores/nbTot);
printf("The best final score is est %4.2f ", bestFinalScore);
printf("The worst final score is %4.2f ", worstFinalScore);
      

   getchar();
   return 0;  
}

/*
Enter the score of judge number 1 : 5.9
Enter the score of judge number 2 : 6
Enter the score of judge number 3 : 5.4
Enter the score of judge number 4 : 5.3
Enter the score of judge number 5 : 5.2
Enter the score of judge number 6 : 5.1
Enter the score of judge number 7 : 5.4
Enter the score of judge number 8 : 5.6
Enter the score of judge number 9 : 5.6

The final score of the skater is 5.49

Do you want to continue ? (y/n) y
Enter the score of judge number 1 : 6
Enter the score of judge number 2 : 4.8
Enter the score of judge number 3 : 5.4
Enter the score of judge number 4 : 5.3
Enter the score of judge number 5 : 6
Enter the score of judge number 6 : 5.4
Enter the score of judge number 7 : 5.2
Enter the score of judge number 8 : 5.8
Enter the score of judge number 9 : 5.9

The final score of the skater is 5.57

Do you want to continue ? (y/n) n
The total number of skaters : 2

The average final score is 1846387878079154500000000000000000.00
The best final score is est 5.57
The worst final score is -0.84

--------------------------------
Process exited after 27.32 seconds with return value 0
Press any key to continue . . .
*/

Explanation / Answer

#include<stdio.h>
#include<float.h>

int main()
{
float score;
float sumScores;
float highScore = FLT_MIN;
float bestFinalScore = FLT_MIN;
float lowScore = FLT_MAX;
float worstFinalScore = FLT_MAX;
int numJudge;
float finalScore;
char answer;
int nbTot =0;
float sumFinScores ;
  
do{ nbTot++;
sumScores = 0;
for (numJudge=1; numJudge<=9; numJudge++)
{
printf("Enter the score of judge number %d : ",numJudge);
fflush(stdin);
scanf("%f", &score );
printf("%f ",score);
sumScores += score;
if(score > highScore)
highScore = score;
if(score < lowScore)
lowScore = score;
  
finalScore = ( sumScores - highScore - lowScore ) / 7 ;
  

  

}
sumFinScores += finalScore;
if(finalScore < worstFinalScore)
worstFinalScore = finalScore;
if(finalScore > bestFinalScore)
bestFinalScore = finalScore;

printf(" The final score of the skater is %4.2f ", finalScore);

printf(" Do you want to continue ? (y/n) ");
fflush(stdin);
scanf("%c", &answer);
printf("%c ",answer);
} while(answer == 'y');
  
printf("The total number of skaters : %d ", nbTot);
  
printf(" The average final score is %4.2f ", sumFinScores/nbTot);
printf("The best final score is est %4.2f ", bestFinalScore);
printf("The worst final score is %4.2f ", worstFinalScore);
  

getchar();
return 0;
}

see the bolded part

you have to caluculate final score only once per candidate hence it have to be moved out side the for loop

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