Question: 1. Write a method named resize that does the following: Takes in an array Creates an array of double its length Copies the values from

1. Write a method named resize that does the following:

Takes in an array

Creates an array of double its length

Copies the values from the original array into the longer array

Returns the longer array containing the values from the original array.

The method signature should be public static int [ ] resize (int [] arr);

Make more than one version of this method so that it works with different types

(int, char, double, String)

2. Write a void method that takes in an array and prints the elements in reverse order.

The method signature should be public static void printArrReverse (String [] arr);

Make more than one version of this method so that it works with different types

(int, char, double, String)

3. Write a void method that does the following:

Takes in 2 arguments, an int and an int[] arr

Iterates through the array

Prints the product of each value in the array multiplied by the int that was passed in.

The method signature should be public static void printValTimesN (int n, int [] arr);

4. Write a method that does the following:

Takes in an array of type String

Uses Math.random to randomly select an index from 0 to the last index of the array

Return the Word located at that index of the array

The method signature should be public static String [ ] getRandomWord (String [] arr);

5. Write a method that does the following:

Takes in 2 arguments, an int and an int[] arr

Iterates through the array to find if there is a value that matches the target

Returns the index if a match was found

Returns -1 if the entire array was traversed without finding a match

The method signature should be public static int findMatch (int target, int [] arr);

6. Write a method that does the following:

Takes in an array containing values of type int

Iterates through the array

Calculates the average and returns it

The method signature should be public static double getAverage (int [] arr);

Test each method by calling it with different values and checking that the output was what you expected.

Hint for the methods that dont print, youll need to store the returned result in a variable before printing it.

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!