Write a Java program to simulate the Find and Replace functions found in word processors.
- String variables
Write a program which can replace a phrase found within a text paragraph with a second phrase. You program needs the following.
- Asks the user to enter a String to search for to be replaced, findThis.
- Asks the user to enter another String to replace the above String, replaceWith.
- You can hard code or ask the user to enter the paragraph of text to search through, inThis.
- Asks the user if they want to replace the first or all occurrences of findThis.
- If the user chooses the first occurrence, find the first occurrence of the String, findThis, inside the String , inThis, and replace it with the String, replaceWith.
- If the user chooses to replace all, replace all the occurrences of findThis in inThis with replaceWith.
- Output the original paragraph of text along with the new paragraph.
- If the search string, findThis, is not found in the paragraph, inThis, report that the string was not found.
Edhesive T1 Lesson 21: Strings
Edhesive T1 Lesson 22: String Methods
AP College Board 2.6: String Objects
AP College Board 2.7: String Method