Java program that determines if two (2) words rhyme. Write the import statements to be able to
Fantastic news! We've Found the answer you've been seeking!
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) 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.
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date: