Write a program that contains a method avgWithoutSmallest. The method should compute the average of an array of values,
Posted: Thu May 05, 2022 1:19 pm
Write a program that contains a method avgWithoutSmallest. The method should compute the average of an array of values, except for the smallest one, in a single loop. In the loop, update the sum and the smallest value. After the loop, return the average of all numbers except the smallest one. The main program should then display the returned value. Hints: The main program should declare and populate the array. Then it should call the method, and display the value returned from the method. The method should have ONE loop that: • Calculates the running total o See "Sum and Average" under Common Algorithms section 6.3 • Tracks the value of the smallest number o See "Maximum and Minimum" under Common Algorithms section 6.3 After the loop, calculate the average of all numbers EXCEPT the smallest The total will be (sum - smallest) • You will divide by (array length - 1)
The method should have ONE loop that: • Calculates the running total o See "Sum and Average" under Common Algorithms section 6.3 • Tracks the value of the smallest number o See "Maximum and Minimum" under Common Algorithms section 6.3 After the loop, calculate the average of all numbers EXCEPT the smallest • The total will be (sum - smallest) • You will divide by (array.length - 1) • Remember to typecast this as a double Create a small array (3 or 4 numbers) at first and check your program's results with a calculator.
The method should have ONE loop that: • Calculates the running total o See "Sum and Average" under Common Algorithms section 6.3 • Tracks the value of the smallest number o See "Maximum and Minimum" under Common Algorithms section 6.3 After the loop, calculate the average of all numbers EXCEPT the smallest • The total will be (sum - smallest) • You will divide by (array.length - 1) • Remember to typecast this as a double Create a small array (3 or 4 numbers) at first and check your program's results with a calculator.