Question: URGENT HELP! Thanks in advance! You will write a program called ArrayMethods that will include many different methods to execute many common array algorithms. Your

URGENT HELP! Thanks in advance!

 URGENT HELP! Thanks in advance! You will write a program called

ArrayMethods that will include many different methods to execute many common array

You will write a program called ArrayMethods that will include many different methods to execute many common array algorithms. Your arrays may be hard coded in your main program or you may challenge your self to accept the arrays through user input (1 point extra with it). The best way to write this program is to write and test each method individually. Do not wait until the entire program is written before you start testing it out. Also, if you are going to try user input, first test your methods with hard coded arrays to rule out any issues with the user input. You should use a range of values and sizes of arrays to test out your code. Check all conditions (for instance, for #6 below, send a target value that will not be found. For instance, for #3 and #4, use different ranges for begin and end index). You should also check that your results seem correct by solving the problem by hand. Listed below are the methods you will need to write with the method declaration line already provided for you (some of these methods may seem familiar). You may write any other methods that you feel may help you to complete this. 1. A method called printArray() that will take in an array of ints and print it out neatly on one line like so: {1, 2, 3, 4} public static void printArray(int[] arr) 2. Another method called printArray() that will take in an array of Strings and print it out neatly on one line like so: {"Hello", "Hi", "Bye"}(remember through method overloading that you can have the same method name in a program as long as the parameter number or datatypes are different. The compiler will know which one to call based on the parameters) public static void printArray(String[] arr) 3. A method called sumRange() that will take an array of ints and a begin and end index and will return the sum of a range of elements from the beginindex to an ending index. For instance, if the array arr is {3,4,5,7} and the begin index is 1 and end index is 3, the sum value returned will be arr[1]+arr[2}+arr[3] = 16 public static int sumRange(int[] arr, int beginIndex, int endindex) 4. A method averageRange() that will take an array of ints and a begin and end index and will return the average of a range of elements from the beginindex to an ending index. For instance, if the array arr is {3,4,5,7} and the begin index is 1 and end index is 2, the average value returned will be (arr[1]+arr[2])/2 = 4.5 public static double averageRange(int[] arr, int beginIndex, int endIndex) 5. A method makeCopy() that will take in an array of Strings and will return an array that is an exact copy (this is a handy method if you do not want to have arrays pointing to the same location in memory like this would do: int[] a ={1,2}; int[] b = a;) public static String[] makeCopy(String[] arr) 6. A method findWord() that will take in an array of Strings and a target word and return the index of the element where the word is found. It will return-1 if it is not found. You can assume that it would not be found more than once. public static int findWord(String[] arr, String target) 7. A method makeReverseCopy() that will return an array that is a reverse of an array of ints sent as a parameter. For instance, if the array sent to the method original is {1,3,5,7} the array to be returned would be {7,5,3,1} public static int[] makeReverseCopy(int[] arr) 8. Your program will obviously have a main method that will do all the execution and calling of the methods that you have written. a. You will declare and initialize your test arrays (an int[] and a String[]), either by hard-coding or accepting via user input, then call printArray() to print both arrays. b. Print out the value of the return of sumRange() in the following format: "The sum of the array {1, 2, 3, 6}from index 2 to index 3 is equal to 9" Print out the value of the return of averageRange() in the following format: C. "The average of the array {1, 2, 3, 6} from index 2 to index 3 is 4.5" d. Call makeCopy() and print out the new array that is the copy in the following format The copy of the array {"Hello", "Hi", "Bye"}is ("Hello", "Hi", "Bye"} e. Print out the return value of findWord() in the following format: "The word Hello was found in the array {"Hello", "Hi", "Bye"}is at index 0" f. Print out the return value of makeReverseCopy) in the following format: "The reverse array of the array {1, 2, 3, 4, 5} is {5, 4, 3, 2, 1}

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!