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

In the sport of diving, seven judges award a score between 0 and 10, where each

ID: 3546364 • Letter: I

Question

In the sport of diving, seven judges award a score between 0 and 10, where each score may be a floating point value. The highest and lowest scores are discarded and the remaining scores are added together. The sum is then multiplied by the degree of difficulty of the dive. The degree of difficult ranges between 1.2 to 3.8 points. this results is then multiplied by 0.6 to determine the diver's score. Ask how many divers are to be evaluated and create an array to hold overall scores. Use this number to create two arrays: a String array to hold the diver names and a double array to hold the overall scores. Then for each diver: Collect the diver's name. Collect the scores from seven judges. I suggest using another double array here (size 7 for the seven judges). Collect the degree of difficulty for the dive. Report the overall score for the dive. Store the score in the overall scores array. Report overall results (diver and score ). Here you will loop over two arrays together (the String and double arrays created at steps a ) and report the final answer.

Explanation / Answer

import


java.util.Scanner;

public


class SportOfDiving

{

public static void main(String[] args)

{

int numberOfDivers;

String diverNames[];

double diverScores[];

double judgesScores[];

double highestScore;

double lowestScore;

double sumOfScores;

double degreeOfDifficulty;

double sumWithDifficulty;

double overallScore;


Scanner input = new Scanner(System.in);


/* (a) */

System.out.print("Enter the number of divers to be evaluated: ");

numberOfDivers = input.nextInt();


diverNames = new String[numberOfDivers];

diverScores = new double[numberOfDivers];

judgesScores = new double[7];


/* (b) */

for(int i = 0; i < numberOfDivers; i++)

{

/* (b.i) */

System.out.print("Enter the name of diver " + (i + 1) + ": ");

diverNames[i] = input.next();


/* (b.ii) */

System.out.println("Enter the scores of 7 judges (each score should be in the range of 0-10):");

judgesScores[0] = input.nextDouble();

highestScore = judgesScores[0];

lowestScore = judgesScores[0];

sumOfScores = judgesScores[0];

for(int j = 1; j < 7; j++)

{

judgesScores[j] = input.nextDouble();


if(judgesScores[j] > highestScore)

highestScore = judgesScores[j];


if(judgesScores[j] < lowestScore)

lowestScore = judgesScores[j];


sumOfScores += judgesScores[j];

}


sumOfScores = sumOfScores - highestScore - lowestScore;


/* (b.iii) */

System.out.print("Enter the degree of difficulty (it should be in the range of 1.2-3.8): ");

degreeOfDifficulty = input.nextDouble();


sumWithDifficulty = sumOfScores * degreeOfDifficulty;


/* (b.iv) */

overallScore = sumWithDifficulty * 0.6;


/* (b.v) */

diverScores[i] = overallScore;

}


/* (c) */

System.out.println();

for(int i = 0; i < numberOfDivers; i++)

{

System.out.println("Name of diver " + (i + 1) + ": " + diverNames[i]);

System.out.println("Score of diver " + (i + 1) + ": " + diverScores[i]);

}

}

}

------------------------------------------------------------------------------------------------------

Sample Output:

Enter the number of divers to be evaluated: 5

Enter the name of diver 1: AAA

Enter the scores of 7 judges (each score should be in the range of 0-10):

5 8 2.5 9 6.5 3.5 4

Enter the degree of difficulty (it should be in the range of 1.2-3.8): 2.0

Enter the name of diver 2: BBB

Enter the scores of 7 judges (each score should be in the range of 0-10):

6 9.5 4 1.5 7 8 3

Enter the degree of difficulty (it should be in the range of 1.2-3.8): 3.8

Enter the name of diver 3: CCC

Enter the scores of 7 judges (each score should be in the range of 0-10):

3.5 9 5 7.5 6.5 4.5 3

Enter the degree of difficulty (it should be in the range of 1.2-3.8): 3.5

Enter the name of diver 4: DDD

Enter the scores of 7 judges (each score should be in the range of 0-10):

7.5

8.5 9.5 6.5 3.5 4.5 5.5

Enter the degree of difficulty (it should be in the range of 1.2-3.8): 1.2

Enter the name of diver 5: EEE

Enter the scores of 7 judges (each score should be in the range of 0-10):

5 6 1 9 8 8 7

Enter the degree of difficulty (it should be in the range of 1.2-3.8): 3.0

Name of diver 1: AAA

Score of diver 1: 32.4

Name of diver 2: BBB

Score of diver 2: 63.83999999999999

Name of diver 3: CCC

Score of diver 3: 56.699999999999996

Name of diver 4: DDD

Score of diver 4: 23.4

Name of diver 5: EEE

Score of diver 5: 61.199999999999996