Question: Description: In this lab you will practice recursion on Strings by writing a program that reverses a string input by the user. You will need

Description: In this lab you will practice recursion on Strings by writing a program that reverses a string input by the user. You will need to write your methods in a class called Reverse.java, which will contain the following methods: 1. static String reverseRec(String s) - A method that uses recursion to reverse the order- ing of the characters in the input String s and returns the reversed String. 2. static String reverseIter(String s) - An iterative (non-recursive) method to reverse the ordering of the characters in the input String s. This method may use any of the techniques for eliminating recursion that we discussed in class. 3. static void main(String[] args) - A main method that repeatedly asks the user to enter a word or phrase, then asks for an integer value 1 or 2. If the user inputs 1 the program should print the input string in reverse using recursion. If the user inputs 2, use the iterative method. Use the character `X' as the command to end the program. Once you are nished, submit ONLY the le Reverse.java.

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!