Question
Hello, this is a practice assignment that we are using for an upcoming test. I am not talented in this department but would really like
Hello, this is a practice assignment that we are using for an upcoming test. I am not talented in this department but would really like to learn. Can someone please do each of these with comments so I know how you did it? Label and space for each problem so I know which is which. Thank You! Java!! Separate each problem and include the main to test in each one. I have to see each as its own program.
Complete the following array problems. Each file you submit should contain a main() method to test your solution which is implemented as a static method.
Problem 1. Concatenate
Write a method that takes two integer array parameters and returns an array that contains all the elements from both arrays
public static int [] concat(int [] arr1, int [] arr2) ;
The concatenation of array {1,2,3} with array [5,6,7,8} would be the array [1,2,3,5,6,7,8}.
Problem 2. Larger Array
Write a method that takes two integer array parameters and returns true if the sum of the numbers in the first array is larger that the sum of the numbers in the second array.
public static boolean larger(int [] arr1, int [] arr2);
Problem 3. Double Odd
Write a method that takes an integer array parameter and replaces each odd number in the array with it's value times 2.
public void doubleOdd(int [] arr);
So this method would change {3,4,5,8,9} into {6,4,10,8,18}
Problem 4. Endsmatch
Write a method that takes an integer array as a parameter and returns true if the first and last values of the array are the same
public static boolean endsMatch(int [] arr);
So, true for {3,2,2,1,3} and false for {3,2,3,2}
Problem 5. Reverse
Write a method that takes an integer array and reverses it:
public static void reverse(int [] arr);
Reversing {1,2,3,4} changes it to {4,3,2,1}. Recall from lecture that you will need a temporary variable to hold one of the values to avoid overwriting an entry and losing the value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started