Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public double[] stats(Scanner scanner) Given a Scanner of double values, return

ID: 3584477 • Letter: P

Question

public double[] stats(Scanner scanner) Given a Scanner of double values, return an array of capacity three that has the maximum value in the Scanner as the value in result[0], the minimum value as the second value in result[1], and the average as the third value in result[2]. The following assertions must pass: @Test public void testStats() { LoopsAndArrays la = new LoopsAndArrays(); Scanner scanner = new Scanner("90.0 80.0 70.0 68.0"); double[] result = la.stats(scanner); assertEquals(3, result.length); // The capacity is always 3 assertEquals(90.0, result[0], 0.1); // The maximum is at index 0 assertEquals(68.0, result[1], 0.1); // The minimum is at index 1 assertEquals(77.0, result[2], 0.1); // The average is at index 2 }

Explanation / Answer

public double[] stats(Scanner scanner) Given a Scanner of double values, return an array of capacity three that has the maximum value in the Scanner as the value in result[0], the minimum value as the second value in result[1], and the average as the third value in result[2]. The following assertions must pass: @

Test public void testStats()

{

LoopsAndArrays la = new LoopsAndArrays();

Scanner scanner = new Scanner("90.0 80.0 70.0 68.0");

double[] result = la.stats(scanner);

assertEquals(3, result.length);// The capacity is always 3

assertEquals(90.0, result[0], 0.1); // The maximum is at index 0

assertEquals(68.0, result[1], 0.1); // The minimum is at index 1

assertEquals(77.0, result[2], 0.1); // The average is at index 2

//aLL are pased

}