Extreme Judgment


Problem Statement

In some Olympic competitions a competitor's score is determined by a panel of judges who each award a score to the competitor. To discount biased judges or statistical outliers the maximal and minimal scores are dropped, then the average of the remaining scores, the average without the two extremes, is the final score awarded.

Write a method getScore that returns the average score after dropping the lowest and highest scores.

Definition

Class

public class Judgment { public double getScore(double[] scores) { // TODO: fill in scores } }

Constraints

  • Each element of scores is between 0.0 and 10.0, inclusive.
  • 3 <= scores.length <= 200 (there are at least 3 scores and no more than 200 scores)

    Examples

    1.   [4.0, 10.0, 5.0]
      
      Returns:  5.0
      
      After throwing out the high/low scores only 5.0 is left.

    2.     
         [8.0, 8.0, 8.0, 8.0] 
      
      Returns:  8.0
      

    3.   [1.75, 1.0, 2.0, 2.25, 1.75, 2.2 ]
      
      Returns:  1.925
      
      1.75 + 2.0 + 1.75 + 2.2 = 7.7
      7.7/4 = 1.925