Question: Java program that determines if two (2) words rhyme. Write the import statements to be able to useScanner,Pattern, andMatcher. Enable user input. Create three (3)
Java program that determines if two (2) words rhyme.
- Write the import statements to be able to useScanner,Pattern, andMatcher.
- Enable user input.
- Create three (3) String variables.
- word1shall store the first word.
- word2shall store the second word.
- subshall store the last two (2) letters ofword1.
- Initialize aPatternas defined by the regular expression"[___]{}" + sub + " "For the first blank, allow uppercase and lowercase letters. For the second blank, allow either 1 or 2 letters beforesub(contains the last two (2) letters ofword1).
- Initialize aMatcherto store a possible match between your pattern andword2.
- Use thematches()method to check if the two (2) words rhyme.
- Loop the program to ask: "Do you want to continue? [y/n]" after a successful try.
Step by Step Solution
There are 3 Steps involved in it
Heres the Java program that determines if two words rhyme based on the provided description import j... View full answer
Get step-by-step solutions from verified subject matter experts
