Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Return the centred average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest

Return the "centred" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore just one copy, and likewise for the largest value. Use int division to produce the final average. You may assume that the array is length 3 or more. centredAverage([1, 2, 3, 4, 100]) image text in transcribed 3 centredAverage([1, 1, 5, 5, 10, 8, 7]) image text in transcribed 5 centredAverage([-10, -4, -2, -4, -2, 0]) image text in transcribed -3

For example:

Test Result
int[] nums = {16, -8, -18, 20, -15, 13, 4, 14, -8, -19, 9, 14, 6, 1, -9}; System.out.println(centredAverage(nums));
1

just write the body, start with

public int centredAverage(int[] nums) { // TODO your code goes here }

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_2

Step: 3

blur-text-image_step3

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

ISBN: B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago