Home /
Expert Answers /
Computer Science /
java-nbsp-pattern-and-matcher-create-a-java-program-that-determines-if-two-2-words-rhyme-1-wr-pa559
(Solved): Java: Pattern and
Matcher
Create a Java program that determines if two (2) words rhyme. 1. Wr ...
Java: Pattern and
Matcher
Create a Java program that determines if two (2) words rhyme. 1. Write the import statements to be able to use Scanner, Pattern, and Matcher 2. Enable user input 3. Create three (3) String variables. • word1 shall store the first word. • word2 shall store the second word. sub shall store the last two (2) letters of word?. 4. Initialize a Pattern as defined by the regular expression "L + sub+**For the first blank, allow uppercase and lowercase letters. For the second blank, allow either 1 or 2 letters before sub (contains the last two (2) letters of word1). 5. Initialize a Matcher to store a possible match between your pattern and word2 6. Use the matches() method to check if the two (2) words rhyme.
Hi there! Here is the Java Source Code which finds out whether the 2 words rhyme or not using Pattern and Matcher. Hope this helps. Support the work by Upvoting{Like}.. import java.util.*; import java.util.regex.Matcher; import java.util.regex.Patter