Question: *Array Methods & For Each LoopInstructions: Complete the following tasks described in pseudocode and submit the java program demonstrating that you have completed each section

*Array Methods & For Each LoopInstructions: Complete the following tasks described in pseudocode and submit the java program demonstrating that you have completed each section 100% correctly.*//* Problem 1a. Complete the for-each loop to print values of thearray called money[] */public class MyMoney{public static void doubleMyMoney(int[] m){ // Payclose attention to how the formal parameter is declared.for(int i = 0; i < m.length; i++){m[i]*= 2;}}public static void main(String [] args){int[] money = {7, 3, 1100, 49};doubleMyMoney(money); // Notice that an array isthe parameter.for( : ){System.out.println( x );}}}/* Problem 1b. Read the code below and then write a comment below listing the elements of numbers[] after the code executes. */int[] numbers = new int[8];numbers[1] = 4;numbers[2] = 99;numbers[3] = 2;int x = numbers[1];numbers[x] = 44;numbers[numbers[7]] = 11; //uses numbers[7] as an index

/* Problem 1c. Write a statement that prints the elements of the numbers[] array. *//* Problem 1d. Read the code below and write a comment below listing the elements of data[] after the code executes. */int[] data = new int[8];data[0] = 3;data[7] = -18;data[4] = 5;data[1] = data[0]; int x = data[4]; data[4] = 6; data[x] = data[0] * data[1];/* Problem 1e. Write a statement that prints the elements of the data[] array.*//*Problem 1f.Write a method called average that computes the average of all elementsin an array of integers and returns the answer as a double. For example,if the array passed contains the values [10, -2, 4, -4, 9, -5, 19, -7, -39, -1],the calculated average should be -1.6. ***Your method must acceptan array of integersas its parameter and returns the average.*** *//* Exercise 2

Problem 2a.Write code that creates an array double the length of the array numbers (from Problem 1b). *//* Problem 2b.Write code that copies the numbers array from index 0 12 + 1). You should assume that the array has at least one element. *//* Exercise 4Write a method called mode that returns the most frequently occurring elementof an array of integers. Assume the array has at least one element and thatevery element in the array has a value between 0 and 100 (inclusive). Breakties by choosing the lower value. For example, if the array passed containsthe values [27, 15, 11, 15, and 27], your method should return 15. */

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!