Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the class Assignment4 which implements some recursive and static methods, as well as a main method to test them. Your program will maintain an

image text in transcribedimage text in transcribedimage text in transcribed

Write the class Assignment4 which implements some recursive and static methods, as well as a main method to test them. Your program will maintain an integer array of size 10 and offer a menu of the following choices to the user until the user chooses to quit: Make sure to print the array after performing the tasks in 1,3,4, and 7 using recPrint in the main method. You may use method overloading to provide a cleaner interface for each method (Helper method). In this case, your recursive helper method should be private. For example: private static int sum(int[] arr, int index) { //Helper-recursive method You can use the following code to print the menu: Question 1.a: Write a recursive method recF Fill that takes an array of int. This method will fill the array with numbers given by the user until here is no more room in the array. The method's header should be: public static void recFill(int[] arr) Question 1.b: Write a recursive method recSum that takes an array of int. This method will recursively calculate the sum of the array's elements and return the result. The method's header should be: public static int recSum(int[] arr) Question 1.c: Write a recursive method recShiftRight that takes an array of int. This method will recursively shift the elements to the right and place the last element in the first index. The method's header should be: public static void recShiftRight(int [] arr) Write a recursive method recShiftLeft that takes an array of int. This method will recursively shift the elements to the left and place the first element in the last index. The method's header should be: public static void recShiftleft(int[] arr) Question 1.e: Write a recursive method recFindMax that takes an array of int. This method will recursively search the array for the maximum element and return it. The method's header should be: public static int recFindMax(int [] arr) Question 1.f: Write a recursive method recFindMin that takes an array of int. This method will recursively search the array for the minimum element and return it. The method's header should be: public static int recFindMin(int [] arr) Question 1.g: Write a recursive method recReverse that takes an array of int. This method will recursively reverse the elements of the array permanently (Do not just print them in reverse). The method's header should be: public static void reckeverse(int [] arr) Question 1.h: Write a recursive method recPrint that takes an array of int. This method will recursively print all the elements in the array. The method's header should be: public static void recPrint(int[] arr)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions