Question: import java.util.*; public class ListSquare { public static void printDoubleList(String name, ArrayList a) { System.out.printf(%20s: , name); if (a == null) { System.out.printf(Null array! );
import java.util.*; public class ListSquare { public static void printDoubleList(String name, ArrayList a) { System.out.printf("%20s: ", name); if (a == null) { System.out.printf("Null array! "); return; } for (int i = 0; i a = new ArrayList(); a.add(3.2); a.add(2.1); a.add(5.3); a.add(8.0); a.add(4.9); a.add(5.7); ArrayList b = new ArrayList(); b.add(1.1); b.add(2.2); b.add(3.3); b.add(4.4); b.add(5.5); b.add(6.6); ArrayList result = listSquare(a); printDoubleList("a", a); printDoubleList("listSquare(a)", result); result = listSquare(b); System.out.printf(" "); printDoubleList("b", b); printDoubleList("listSquare(b)", result); } } 
Task 6 (10 pts.) File ListSquare.java contains an incomplete program. The goal of the program is to compute the position-wise squares of the values of an array list. Complete that program, by defining a listsquare function, that satisfies the following specs: Function 1istsquare takes one argument, called A, that is an array list of double numbers. The function should retun an array list called result, with length equal to the length of A, such that the value at position i of result is square of the value at position iofA IMPORTANT: You are NOT allowed to modify in any way the main function. You are free to define and use auxiliary functions The complete program should produce this output: a: 3.20 2.10 5.3 8.0 4.90 5.70 listSquare (a) 10.24 4.41 28.89 64.00 24.01 32.49 b: 1.10 2.28 3.30 4.40 5.50 6.60 listSquare(b): 1.21 4.84 10.89 19.36 30.25 43.56
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
