Question
IN JAVA Write two recursive methods called deleteFirst and deleteAll. Both methods have two parameters, a string str, and a character ch. In the deleteFirst
IN JAVA
Write two recursive methods called deleteFirst and deleteAll. Both methods have two parameters, a string str, and a character ch. In the deleteFirst method, delete the first occurrence of ch in the string strand return the new string. In the deleteAll method, deleteall the occurrences of chin the string strand return the new string. In both cases, if chis not in string str, return the original string. Both methods have to be recursive.Also write a main method to test the two recursive methods. Your main method should print a menu as the following: 1.Test deleteFirst method 2.Test deleteAll method 3.ExitThe menu should be repeated until user selects 3 to exit. For each testing, your program should ask user to enter the input string and a character, each on a separate line, and then print the output string after calling the corresponding method.Place all three methods in the same class. Name your class as RecursionTest.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started