17.2k views
1 vote
write a function that returns a list, where each member of list contains previous day’s value multiplied by 2.​

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Java, the function takes in a list with the previous day's values. The function then uses that list, loops through it and multiplies each individual value by 2 and returns the modified list. The first red square represents the test case for the function, while the second red square in the image represents the output.

public static ArrayList<Integer> doubleIt(ArrayList<Integer> mylist) {

for (int x = 0; x<mylist.size(); x++) {

mylist.set(x, mylist.get(x)*2);

}

return mylist;

}

write a function that returns a list, where each member of list contains previous-example-1
User Eric Petroelje
by
4.6k points