Example of an array in java using a sample program.

Write all the code for a class called ArrayQsn. This class will contain two methods. The first method runningSumMean accepts an array of ints as a parameter, and will return the mean of the values as a double. It also changes the values of the array so that they are running sum values.
For example, the array:
{2, 4, 5, 1, 3}
Would become:
{2, 6, 11, 12, 15}
after the method is called. Do not write more than one loop inside the method. Your method must accept any size array.
If the array is empty (no values), then provide an error message to the screen and return zero.
The second method is the "main" method. Use it to test the runningSumMean method with the array given above. The main method must provide output to the screen that would look like:

Mean = 3
Array: 2, 6, 11, 12, 15

© SolutionLibrary Inc. solutionlibary.com 9836dcf9d7 https://solutionlibrary.com/computer-science/data/example-of-an-array-in-java-using-a-sample-program-32d

Solution Preview

... == 0) {System.out.println ("Warning, empty array!");
return 0;}
int size = anArray.length;
for (int i = 1; i < size; i++)
anArray[i] += anArray[i - 1];
// must cast to ...