Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. In an international ballroom dancing competition, competitors are scored by a panel of judges on a scale from 0 to 100. The final score

3.

In an international ballroom dancing competition, competitors are scored by a panel of judges on a scale from 0 to 100. The final score for each couple is computed as the average of the scores from all the judges. However, if the number of judges is equal to or greater than 6, and the highest score is given by only one judge, that score is excluded from computing the average. The same applies to the lowest score.

  1. Write a method countOccurrences that returns the number of occurrences of a given target value in a given array. Complete the method countOccurrences below.

    Question 3(a)

    • /** Returns the number of times target occurs among the values * in the given array * @param scores an array of values * @param target the target value * @return the number of times target appears among the * values in scores */ public static int countOccurrences(int[] scores, int target)

  2. Write a method findMaxAndMin that takes an array scores as a parameter and returns an array of length two, where the first element is the maximum value in scores and the second element is the minimum value in scores. Complete the method findMaxAndMin below.

    Question 3(b)

    • /** Returns an array of two elements in which * the first element is the maximum value in scores and * the second element is the minimum value in scores * Precondition: scores.length > 0; 0 <= scores[k] <= 100 */ public static int[] findMaxAndMin(int[] scores)

  3. Write a method averageScore that takes an array scores as a parameter and computes and returns the average score. However, if the size of the array scores is 6 or greater, and the maximum value occurs only once in the array, that value is excluded from computing the average. The same is done for the minimum value.

    In writing this method, assume that the methods countOccurrences from Part (a) and findMaxAndMin from Part (b) work as specified, regardless of what you wrote there. You may not receive full credit if instead of calling these methods you write equivalent code here. Complete the method averageScore below.

    Question 3(c)

    • /** Returns the average 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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago