Question: Problem 1 (Programming I review 15 points) Write a Java program that will declare and initialize an array of 8 integers to some set of
Problem 1 (Programming I review 15 points) Write a Java program that will declare and initialize an array of 8 integers to some set of integers. You may hardwire your values, rather than reading input. The program should call a method public static void displaySums(int[] someArray) that will calculate the total for the odd indices and the total for the even indices. For example if myArray = {1,2,3,4,5,6,7,8} the following output would be expected. The sum of the odd indices is 20 //2 + 4 + 6 + 8 the comments are not part of the output The sum of the even indices is 16 //1 + 3 +5 + 7 Hints: i % 2 == 0 //even i %2 == 1 // odd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
