Answered step by step
Verified Expert Solution
Link Copied!

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.

  1. Write the import statements to be able to useScanner,Pattern, andMatcher.
  2. Enable user input.
  3. Create three (3) String variables.
    • word1shall store the first word.
    • word2shall store the second word.
    • subshall store the last two (2) letters ofword1.
  4. 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).
  5. Initialize aMatcherto store a possible match between your pattern andword2.
  6. Use thematches()method to check if the two (2) words rhyme.
  7. 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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions