USE JAVA

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

USE JAVA

Post by answerhappygod »

USE JAVA
Use Java 1
Use Java 1 (69.34 KiB) Viewed 34 times
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 }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply