Question: Write a program named SumArrayList.java. Your program should create an ArrayList of type Double. For example: ArrayList list = new ArrayList(); Prompt the user to
Write a program named SumArrayList.java. Your program should create an ArrayList of type Double. For example:
ArrayListlist = new ArrayList();
Prompt the user to enter numbers with the number 0 serving as the sentinel value. Store the numbers in the ArrayList. Call the sum method to get the sum of the elements in the array list and output the result.
The sum method should have a parameter that is an ArrayList of type Double. It should have a return type of Double that is used to return the sum of the elements in the ArrayList. Use the following method header:
// Sum elements in the array list public static double sum(ArrayListlist)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
