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: 3584466 • 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() { Scanner scanner = new Scanner("90.0 80.0 70.0 68.0"); double[] result = myFun.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 static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);int k if(i > j) System.out.println(i+" is greater than "+j); else System.out.println(j+" is greater than "+i); k=(i+j)/2; }