USE JAVA
Using the code below as a starting point, write a program that uses an array of integers (like the one given, but I will test arrays of different sizes and with different numbers). This program should print 3 values in the following order: 1. The sum of all elements in the array 2. The sum of the first half of the array minus the sum of the second half of the array (if there is an odd number of elements you can completely ignore the middle element). 3. Return the index of the last occurrence of the number 7 in the array. There can be 0 or more elements that match the number 7. If there are 0 elements that match the number, print -1, otherwise only print the last element. public class MidtermExamPart1 { public static void main(String[] args) { int[] myArray = {1, 2, 3, 4, 5, 6, 7, 7, 10, 17}; processArray (myArray); } public static int[] processArray (int[] myArray) { // Your code here }
USE JAVA
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am