Create a Java Project (and package) named Lab8 Make the main class with the name Lab8_706 A local array named arr1 has been declared and initialized inside of main A local array named data2 has been declared and initialized inside of main A local array named data4 has been declared and initialized inside of main Below the main() method, write a NEW public static method named mergeIt2 with two integer array parameters and a return type of integer array Declare a local integer array and size the array to the exact length so it can hold the values from BOTH sorted input arrays Write the code to merge the sorted input arrays into the larger local array such that the data is in sorted order Return the sorted local array to the caller of the method mergeIt2 For example, if the input arrays contained 10,30 and 20,40 the method will return an array containing 10,20,30,40 Below the main() method, write a NEW public static method named median with one integer array parameter and a simple integer return type It will look at the first, middle and last items in the array parameter. Move the smallest value to the beginning, the largest to the end and the median to the middle. Return the median value of the three numbers Inside the main() method: Declare a local variable named arr3 as an integer array Declare local variables named test1, test2 as integers Call the method mergeIt2 and pass it the parameters arr1, data2 and assign the result to arr3 Assign the value in arr3[ 1 ] to the variable test1 Assign the value in arr3[ 4 ] to the variable test2 Declare a local int variable named part_val and assign it the initial value of -1 Declare local variables named test3, test4 as integers Call the method named median, pass it the parameter data4 and assign the return value to part_val Assign the value in data4[ 0 ] to the variable test3 Assign the value in data4[ 8 ] to the variable test4 Print the message 'The method median returned ' plus the value in the variable part_val
Create a Java Project (and package) named Lab8
Make the main class with the name Lab8_706
A local array named arr1 has been declared and initialized inside of main
A local array named data2 has been declared and initialized inside of main
A local array named data4 has been declared and initialized inside of main
Below the main() method, write a NEW public static method named mergeIt2 with two integer array parameters and a return type of integer array
Declare a local integer array and size the array to the exact length so it can hold the values from BOTH sorted input arrays
Write the code to merge the sorted input arrays into the larger local array such that the data is in sorted order
Return the sorted local array to the caller of the method mergeIt2
For example, if the input arrays contained 10,30 and 20,40 the method will return an array containing 10,20,30,40
Below the main() method, write a NEW public static method named median with one integer array parameter and a simple integer return type
It will look at the first, middle and last items in the array parameter. Move the smallest value to the beginning, the largest to the end and the median to the middle.
Return the median value of the three numbers
Inside the main() method:
Declare a local variable named arr3 as an integer array
Declare local variables named test1, test2 as integers
Call the method mergeIt2 and pass it the parameters arr1, data2 and assign the result to arr3
Assign the value in arr3[ 1 ] to the variable test1
Assign the value in arr3[ 4 ] to the variable test2
Declare a local int variable named part_val and assign it the initial value of -1
Declare local variables named test3, test4 as integers
Call the method named median, pass it the parameter data4 and assign the return value to part_val
Assign the value in data4[ 0 ] to the variable test3
Assign the value in data4[ 8 ] to the variable test4
Print the message 'The method median returned ' plus the value in the variable part_val

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 7 images









