Question: JAVA Eclipse. Please help! Write a recursive method that accepts a string as its argument and returns the string in reverse order. The method should
JAVA Eclipse. Please help!
Write a recursive method that accepts a string as its argument and returns the string in reverse order. The method should return the same string if the string length is less than 2 characters long. The main program should ask the user to enter a string, which is then reversed using the above method and printed on the console. The program then prompts the user to enter another string. If the user enters QUIT (case insensitive), then exit the program.
View required output
Test Case 1
| Standard Input |
|---|
abcdENTER quitENTER |
Please enter a string for reversal or type QUIT to exit: Reversed string: dcba Please enter a string for reversal or type QUIT to exit:
Test Case 2
| Standard Input |
|---|
aENTER ENTER xyzENTER quitENTER |
Please enter a string for reversal or type QUIT to exit: Reversed string: a Please enter a string for reversal or type QUIT to exit: Reversed string: Please enter a string for reversal or type QUIT to exit: Reversed string: zyx Please enter a string for reversal or type QUIT to exit:
Test Case 3
| Standard Input |
|---|
quitENTER |
Please enter a string for reversal or type QUIT to exit:
Test Case 4
| Standard Input |
|---|
0123456789ENTER quitENTER |
Please enter a string for reversal or type QUIT to exit: Reversed string: 9876543210 Please enter a string for reversal or type QUIT to exit:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
