Question: Write a Java program, called VariousArrayTasks that has 4 static methods called fillArray (), sumArray () , avgArray(), and printArray(). The fillArray() method should use

Write a Java program, called VariousArrayTasks that has 4 static methods called fillArray (), sumArray () , avgArray(), and printArray(). The fillArray() method should use a Scanner to take in a number representing the length of the array and then read in numbers to fill the array. This array will be an int array. The fillArray() method should take no input and return an int array. It should be called from the main method. The sumArray() method should take an int array as its input parameter and returns an integer value that is the sum of all the elements in the array. The avgAmay () method should take an int array as its input parameter and return a double value that is the average of all the elements in the array. The printArray() method should take an int array as its input parameter and has no return value. It should then print out the elements of the array on the same line separated by a space (- "). All methods should work for integer arrays. Input n, where n is the length of the array, followed by n numbers Output The program should print to the screen the sum of all the elements in the array, and the average of all the elements in the array followed by the array elements printed to the screen separated by a space. Sample Output Sum=9Average=3.023.4 Note: In the fillArray method you should close your Scanner when you are finished taking input. Please ask your demonstrator to explain this. The Message for sum is: "Sum = " and the message for average is: "Average = ". In your code these should match EXACTLY to pass all test cases
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
