2 In a gymnastic or diving competition each contestants scor

2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.
Write a JAVA program that first asks user to enter the number of contestants. Then the program should read the score of 8 judge\'s for each contestant.
The program should display as shown in sample output.
Note: to find out the average score, use number of judges as 6 not 8 because we drop maximum and minimum scores.
a) the name of contestants and score from all 8 judges as shown in sample output.
b) the total score of each contestant (total score is the average of scores after removing the highest and lowest scores).
c) the highest total score amongst the contestants. (which is the average highest score).
d) the lowest total score amongst the contestants. (which is the average lowest score).
Your input file for score should look like
5
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Here the first number in your input file is the number of contestants.
Hint: Use 2-D array
Sample output:
The number of contestants is 5

Contestant Scores
_________________________________________________
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Total score of Albert is 9.48
Total score of John is 9.43
Total score of Jay is 9.37
Total score of Henry is 9.52
Total score of Walter is 9.32

The highest total score amongst the contestants is 9.52
The lowest total score amongst the contestants is 9.32

2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.
Write a JAVA program that first asks user to enter the number of contestants. Then the program should read the score of 8 judge\'s for each contestant.
The program should display as shown in sample output.
Note: to find out the average score, use number of judges as 6 not 8 because we drop maximum and minimum scores.
a) the name of contestants and score from all 8 judges as shown in sample output.
b) the total score of each contestant (total score is the average of scores after removing the highest and lowest scores).
c) the highest total score amongst the contestants. (which is the average highest score).
d) the lowest total score amongst the contestants. (which is the average lowest score).
Your input file for score should look like
5
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Here the first number in your input file is the number of contestants.
Hint: Use 2-D array
Sample output:
The number of contestants is 5

Contestant Scores
_________________________________________________
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Total score of Albert is 9.48
Total score of John is 9.43
Total score of Jay is 9.37
Total score of Henry is 9.52
Total score of Walter is 9.32

The highest total score amongst the contestants is 9.52
The lowest total score amongst the contestants is 9.32

2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.
Write a JAVA program that first asks user to enter the number of contestants. Then the program should read the score of 8 judge\'s for each contestant.
The program should display as shown in sample output.
Note: to find out the average score, use number of judges as 6 not 8 because we drop maximum and minimum scores.
a) the name of contestants and score from all 8 judges as shown in sample output.
b) the total score of each contestant (total score is the average of scores after removing the highest and lowest scores).
c) the highest total score amongst the contestants. (which is the average highest score).
d) the lowest total score amongst the contestants. (which is the average lowest score).
Your input file for score should look like
5
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Here the first number in your input file is the number of contestants.
Hint: Use 2-D array
Sample output:
The number of contestants is 5

Contestant Scores
_________________________________________________
Albert 9.2 9.3 9.0 9.9 9.5 9.5 9.6 9.8
John 9.1 9.4 9.6 9.8 9.4 9.3 9.9 9.1
Jay 9.2 9.3 9.0 9.9 9.4 9.3 9.9 9.1
Henry 9.4 9.3 9.9 9.1 9.5 9.5 9.6 9.8
Walter 9.2 9.3 9.4 9.3 9.9 9.1 9.6 9.0

Total score of Albert is 9.48
Total score of John is 9.43
Total score of Jay is 9.37
Total score of Henry is 9.52
Total score of Walter is 9.32

The highest total score amongst the contestants is 9.52
The lowest total score amongst the contestants is 9.32

Solution

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class MaxScore {
   public static void main(String args[]) throws FileNotFoundException{
      
       Scanner sc = null;
       sc = new Scanner(new File(\"/home/kumar/Desktop/input.txt\")); //Add the input File name here
//       sc = new Scanner(System.in); // Uncomment this line, if you want to take input from console
       final int noOfScores = 8;
       int noOfContestants = sc.nextInt();
       double[][] scores = new double[noOfContestants][noOfScores];
       String[] constestantNames = new String[noOfContestants];
       double[] avgValues = new double[noOfContestants];
      
       for(int contestant = 0; contestant < noOfContestants; contestant++){
           double minScore = Integer.MAX_VALUE;
           double maxScore = Integer.MIN_VALUE;
           String name = sc.next();
           constestantNames[contestant] = name;
           double sum = 0;
           for(int index = 0; index < noOfScores; index++){
               scores[contestant][index] = sc.nextDouble();
               sum += scores[contestant][index];
               if(scores[contestant][index] > maxScore) maxScore = scores[contestant][index];
               if(scores[contestant][index] < minScore) minScore = scores[contestant][index];
           }
           sum -= (minScore + maxScore);
           avgValues[contestant] = sum / (noOfScores -2);
       }
      
       /** Now print the result **/
       System.out.println(\"The number of contestants is \"+ noOfContestants);
       System.out.println();
       System.out.println(\"Contestant\\tScores\");
       System.out.println(\"________________________________________\");
       System.out.println();
       for(int constentant =0; constentant < noOfContestants; constentant++){
           System.out.print(constestantNames[constentant]+\"\\t\");
           for(int index=0; index < noOfScores; index++){
               System.out.print(scores[constentant][index]+\" \");
           }
           System.out.println();
       }
       System.out.println();
       int highestContestant = 0;
       int lowestContestant = 0;
       for(int constentant =0; constentant < noOfContestants; constentant++){
           System.out.println(\"Total score of \" + constestantNames[constentant] + \" is \" + (double)Math.round(avgValues[constentant] * 100d) / 100d);
           if(avgValues[constentant] > avgValues[highestContestant]) highestContestant = constentant;
           if(avgValues[constentant] < avgValues[lowestContestant]) lowestContestant = constentant;
       }
       System.out.println();
       System.out.println(\"The highest total score amongst the contestants is \"+(double)Math.round(avgValues[highestContestant] * 100d) / 100d);
       System.out.println(\"The lowest total score amongst the contestants is \"+(double)Math.round(avgValues[lowestContestant] * 100d) / 100d);
       sc.close();
   }
}

 2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.
 2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.
 2. In a gymnastic or diving competition, each contestant\'s score is calculated by dropping the lowest and highest scores and then adding the remaining scores.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site