Hi,

I'm a beginner at java programming and I've got some trouble with creating an array containing cumulative values of the original array.

For example - given { 1, 2.01, 3, 4, 5, 6 }, use code to get an array {1, 3.01, 6.01, 10.01, 15.01, 21.01 }.

The code I have at the moment is:

Code Java:

public double[] accumulate() { double[] accumulate; accumulate = new double[observations.length]; accumulate[0] = observations[0]; for (int i=1; i < observations.length.length; i++) { accumulate[i] = observations[i]+ observations[i-1] ; } return accumulate; }

where "observations[]" is the original array we're given.

I don't know where I'm going wrong, but where I'm supposed to get 6.01 I get 5.01 instead. Any help or advice would be appreciated :)