Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is a Java program with methods to fulfill the requirements java public class ArrayMethods publi... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial and Managerial Accounting Information for Decisions

Authors: John Wild, Ken Shaw, Barbara Chiappetta

5th edition

978-1259317552, 1259317552, 978-0078025600, 78025605, 978-1259335013, 1259335011, 978-1259347641

More Books

Students also viewed these Accounting questions