Question: rite a method called runningTotal that returns a new ArrayIntList that contains a running total of the original list. In other words, the iith value
rite a method called runningTotal that returns a new ArrayIntList that contains a running total of the original list. In other words, the iith value in the new list should store the sum of elements 0 through ii of the original list. For example, given a variable list that stores [2, 3, 5, 4, 7, 15, 20, 7], consider what happens when the following call is made:
ArrayIntList list2 = list.runningTotal();
The variable list2 should store [2, 5, 10, 14, 21, 36, 56, 63]. The original list should not be changed by the method. If the original list is empty, the result should be an empty list. The new list should have the same capacity as the original. Remember that there is a list constructor that accepts a capacity as a parameter.
The program needs to be in Java. Please also create a Main program to test the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
