public class DiveHelper
{
	/**
		This method takes an array of judges scores and the degree
		of difficulty of the dive and returns the calculated score
	 	@param judges list of judges scores
		@param dd     degree of difficulty
		@return       the score for the individual dive
	 */
	public static double calcScore(double[] judges, double dd)
	{
		double [] scores;
		double sum;
		double result;
		
		// Strip top and bottom scores
		scores = stripHiLo(judges);
			
		// sum the remaining scores
		sum = 0;
		for (int ii = 0; ii < scores.length; ii++)
			 sum += scores[ii];
		
		result = sum * dd;
		
		return result;
	}
	
	/** this method takes the highest and lowest score of the array and 
	 *  throws them out, returning an array that is two elements smaller
	 *  than the original.
	 *
	 * @param original the original set of scores
	 * @return a new array with the middle set of scores
	 */
	public static double[] stripHiLo(double[] original)
	{
		double[] scorable;
		double max, min;
		int ii, jj;
		
		scorable = new double [original.length - 2];
		
		max = Statistics.max(original);
		min = Statistics.min(original);
		
		jj = 0;
		for (ii = 0; ii < original.length; ii++)
		{
			if (!(original[ii] == max || original[ii] == min))
			{
				scorable[jj] = original[ii];
				jj++;
			}
		}
		
		return scorable;
	}
}		
		
		