Array Methods Download ArrayMethods.java. This will be your template for the assignment. Write a java program that
Question:
Array Methods Download ArrayMethods.java. This will be your template for the assignment. Write a java program that has the following methods. Each method must be implemented using for loops:
1. printArray for chars: A method that prints out the values of a one dimensional array of char’s. Values must be printed on separate lines. Method signature: public static void printArray(char[] array)
2. printArray for ints: A method that prints out the values of a one dimensional array of int’s. Values must be printed on separate lines. Method signature: public static void printArray(int[] array)
3. shiftDown: A method that shifts the values of a character array down starting at a given index. Method signature: public static void shiftDown(char[] array, int index) For example, if the array before calling swap is a,b,c and the method call is shiftDown(array, 0) then the resulting array will be a,a,b Array before Array after calling shiftDown(array,0) a b c Additional clarification on method 4, shiftDown: If the array contains H O W D Y and you are shifting down from index 0 you should get H H O W D If the array contains H O W D Y and you are shifting down from index1 you should get H O O W D If the array contains a b c d e and you are shifting down from index 2 you should get a b c c d Hint: Looping in reverse from high indices to low indices makes shiftDown easier to implement.
4. findMinValue: A method that returns the smallest value in an array of int’s. Method signature: public static int findMinValue(int[] array) For example, given the array below, the method should return the value
5. Because 5 is the smallest value in the array. 10 5 8 a a b 5. findMinIndex: A method that returns the index at which the smallest value is located in an array of int’s. This is different from the previous question! Method signature: public static int findMinIndex(int[] array) For example, given the array below, method should return the index 1, because the smallest value is at index 1. 10 5 8
6. copy: A method that copies the values of a given character array into a new array and returns the new array. Method signature: public static char[] copy(char[] fromArray)
Financial and Managerial Accounting Information for Decisions
ISBN: 978-1259347641
5th edition
Authors: John Wild, Ken Shaw, Barbara Chiappetta