Question: ition: The nums array remains unchanged dition: The new array will be the same length as nums public static int[] arrayMixup (int[] nums) } b)

![be the same length as nums public static int[] arrayMixup (int[] nums)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f300d43a737_49166f300d39606f.jpg)

ition: The nums array remains unchanged dition: The new array will be the same length as nums public static int[] arrayMixup (int[] nums) } b) The greatestDifference method will be provided an integer array as its parameter. It will compute the difference between each element of this array and each corresponding element of the array returned when calling the arrayMixup method and passing it this array as its parameter. The greatestDifference method will return the greatest difference as a positive number. You can use any other static methods from the ArrayFun class while coding this method. Example: Suppose that the nums array contains the following elements: {5, 10, 3, 9, 15,4} Note that calling arrayMixup(nums) would return an array with the following elements: {5, 6, 3, 45, 3,4} Therefore calling greatestDifference(nums) would return the greatest difference of 36 since the corresponding difference are: 0, 4,0,-36, 12, 0. Complete the greatestDifference method below. This method will calculate the difference between the corresponding elements from the nums array and the array produced when calling arrayMixup. It will return the greatest * difference as a positive number. * Pre-condition: nums and the array from arrayMixup are of * the same length public static int greatestDifference (int[] nums) { 18 20 21 22 // To be implemented in PART B) below } // other methods not shown } a) The arrayMixup method will go through all the elements in the nums array and use the following logic to populate elements in a new array: The first and last elements in the new array should contain the corresponding first and last elements from the nums array. For all other nums array elements, check to see if the current element is evenly divisible by the previous element (i.e. there is no remainder when dividing the element byt element). If this is the case, then divide the current element by the previous element and multiply this outcome by the next element. Modify the corresponding element in this end result. Otherwise, if the current element is greater than the next elemert, divide the current element by the next element and store the result in the corresponding element of the Else copy the current element to the corresponding element of the new array. There will be at least 3 elements in the nums array and all elements will be greater than zero. The nums array must remain unchanged after the method is executed. The new arra this method will be the same length as the nums array. Example: Suppose that the nums array contains the following elements: {5, 10, 3, 9, 15,4} then calling arrayMixup(nums) would return an array with the following elements: {5,6,3, 45, 3, 4) Complete the arrayMixup method below. * This method is described above. @param nums is an array of integers Pre-condition: All elements in nums will be greater than zero * Pre-condition: There will be at least 3 elements in the nums array * Post-condition: The nums array remains unchanged * Post-condition: The new array will be the same length as nums nhlic static int narraumi xunlint ni nums) Question For the following ArrayFun FRQ, make sure to complete parts a and b in the same text box and remember to label them as part a) and Part b). Good Luck! The ArrayFun class contains static methods that perform fun mathematical computations with arrays. There are two methods that you are asked to complete in this class. A partial definition of the ArrayFun class is shown below. public class ArrayFun { * This method will be described in PART A below. * @param nums is an array of integers * Pre-condition: All elements in nums will be greater than zero * Pre-condition: There will be at least 3 elements in the nums array * Post-condition: The nums array remains unchanged * Post-condition: The new array will be the same length as nums public static int[] arrayMixup (int[] nums) { // To be implemented in PART A) below } /** *This method will calculate the difference between the * corresponding elements from the nums array and the array * produced when calling arrayMixup. It will return the greatest * difference as a positive number. * Pre-condition: nums and the array from arrayMixup are of the same length G public static int greatestDifference (int[] nums) 1/ To be implemented in PART B) below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
