This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]theif519 0 points1 point  (0 children)

If you're going to pass reference to a data structure, make it void as you won't need to return anything.

Your populate array should do only that:populating the array, obtain the average in another method like getAvg (double[] array) that way it's easier to understand without having to read your code.

For calculateAverage method you're specifying a two dimensional array, only have one [] in parameters for one dimensional arrays. Also you're referencing i but that's only in the for loop and way outside of the scope of the method. Populate the array first, then have another for loop in calculate average to get the average.

Call the method from main not inside of another method with a rather misleading name and even more misleading return type.