Explore BrainMass

Explore BrainMass

    Example of an array in java

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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

    © BrainMass Inc. brainmass.com February 24, 2021, 2:07 pm ad1c9bdddf
    https://brainmass.com/computer-science/arrays/example-of-an-array-in-java-3149

    Solution Preview

    public class ArrayQsn {public static double runningSumMean (int[] anArray) {
    if (anArray == null) {System.out.println ("Warning, empty array!");
    return 0;}
    if ...

    Solution Summary

    Example of an array in java is provided.

    $2.19

    ADVERTISEMENT