Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Heres the Java program that determines if two words rhyme based on the provided description import j...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