Question: IN JAVA PP 10* 2 This program adds up all the integer numbers stored in an array and calculates the average. 3 * The average

IN JAVAIN JAVA PP 10\* 2 This program adds up all the integer

PP 10\* 2 This program adds up all the integer numbers stored in an array and calculates the average. 3 * The average is printed. 4 * For example, if the numbers are 1, 3, 5 then the average is (1+3+5)/3 = 4.5 5 * Difficulty: Easy 6 */ 7 public class Array Average 8 { 90 public static void main(String[] args) 10 { 11 int[] data = {2, 34, 57, 31, 5, 79, 88, 62, 98, 53, 42}; 12 13 // -Start below here. To do: approximate lines of code = 4 14 // 1. set a variable total to zero ; Hint: use a double!! 15 16 17 1/2. use a for loop to add up all the integers in data. Recall we know the length of an array .length 18 // i.e. data. length 19 20 21 22 23 //3. compute the average 25 26 27 28 29 30 } // -End here. Please do not remove this comment. Reminder: no changes outside the todo System.out.printf("Average = %.2f ", average); System.out.println("EXPECTED:"); System.out.println("Average 50.09") ; = }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!