Share
Explore BrainMass

Program to Calculate Diver Scores

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 thrown out and the remaining scores are added together. The sum is then multiplied by the degree of difficulty for that dive. The degree of difficulty ranges from 1.2 to 3.8 points. The total is then multiplied by 0.6 to determine the diver's score.

Write a computer program that inputs a degree of difficulty and seven judges' scores and outputs the overall score for that dive. The program should ensure that all inputs are within the allowable data ranges.

HINT:

Use an array to store the scores. Scan the array for the position of the largest and smallest values, then ignore these positions when computing the sum of the scores.

Consider the case where all judges give the diver the same score. In this case, the largest and smallest values will be the same. Make sure that your solution handles this case properly.

/**
* This program calculates the score for a contestant in diving.
* The highest and lowest scores are thrown out, the remaining are added
* together, and the sum multiplied by the degree of difficulty
* and 0.6.
* <P>
* This program uses an array to hold the seven scores, then
* scans the array for the position of the largest and smallest
* score. These positions are then ignored in computing the sum
* of the scores.
*/
import java.util.Scanner;

public class Diving {

public static void main(String[] args) {
double[] scores = new double[7];
int posMinScore, posMaxScore;
double sum = 0;
double difficulty;
double finalscore;

// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------

// --------------------------------
// --------- END USER CODE --------
// --------------------------------

System.out.println("The diver's final score is " + finalscore);
}
}

Solution Summary

.java file attached contains a program that will take in judge scores and difficulty level and output a diver's final total.

$2.19