3.
In an international ballroom dancing competition, competitorsare scored by a panel of judges on a scale from 0 to 100. The finalscore for each couple is computed as the average of the scores fromall the judges. However, if the number of judges is equal to orgreater than 6, and the highest score is given by only one judge,that score is excluded from computing the average. The same appliesto the lowest score.
Write a method countOccurrences that returns the number ofoccurrences of a given target value in a given array. Complete themethod countOccurrences below.
Write a method findMaxAndMin that takes an array scores as aparameter and returns an array of length two, where the firstelement is the maximum value in scores and the second element isthe minimum value in scores. Complete the method findMaxAndMinbelow.
Write a method averageScore that takes an array scores as aparameter and computes and returns the average score. However, ifthe size of the array scores is 6 or greater, and the maximum valueoccurs only once in the array, that value is excluded fromcomputing the average. The same is done for the minimum value.
In writing this method, assume that the methods countOccurrencesfrom Part (a) and findMaxAndMin from Part (b) work as specified,regardless of what you wrote there. You may not receive full creditif instead of calling these methods you write equivalent code here.Complete the method averageScore below.
Question 3(c) /** Returns theaverage of the values in scores. However, * if the size of the array scores is not less than 6 and * the largest value occurs only once in scores, that value * is excluded from computing the average; the same for * the smallest value. * Precondition: scores.length >= 3; 0 <=scores[k] <= 100 */ public static double averageScore(int[] scores)
|