Question: IN JAVA, Write two recursive methods and name both methods as substringRecursive. Both methods are similar to the substring method in the String class, but
IN JAVA, Write two recursive methods and name both methods as substringRecursive. Both methods are similar to the substring method in the String class, but they need to be written as recursive methods. One version has two parameters, a string and the beginning index. It returns the substring from the beginning index to the very end. Another version has three parameters, a string, the beginning index, and the ending index. It returns the substring from the beginning index up to the ending index (excluding the ending index). Both methods need to be recursive.
You are not allowed to use the substring method in the String class.
You also need to write a main method to test the two recursive methods. Your main method should print a menu such as the following:
1. Test two-parameter substringRecursive method
2. Test three-parameter substringRecursive method
3. Exit The menu should be repeated until user selects 3 to exit.
For each testing, your program should ask user to enter the input string, the beginning index, and the ending index (for the three- parameter method only), each on a separate line, and then print the output string after calling the corresponding method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
