In this program, you'll learn to Calculate Sum & Average of an Array. This is done by using for loop.
First of all we have to define a class name "Average" that has int type array to contain some values .Now we take a double type data that calculates the average of array ( avg = sum / array.length). And finally it will display the result on the command prompt with message by using the System.out.println().
Calculate Sum & Average of an Array
When you run the program, the output will be:
Enter the length of the Array : 5Array Element 0 : 25Array Element 1 : 65Array Element 2 : 30Array Element 3 : 99Array Element 4 : 48Sum = 267Average = 53.4