Project #4: Palindrome
Identify if a word is spelled the same forward and backward



  • Write a program that recursively checks if a word is a palindrome

  • Your program must ignore case, spacing, numbers, and symbols


Part A - Input / Output

    • Write the user interface for your program

      • It should loop until the user inputs "q" to quit

      • Ask the user for a palindrome and store it

      • Print out the "clean" message to the user

      • Call the isPalindrome method from wordsmith on the clean message

      • Output the result to the user

    • Make sure the interface is clear + user friendly

Part B- Cleaning the String

  • Your method should return a string that contains only lowercase letters.

  • Think carefully about the best way to do this!

    • Hint #1: Do you want to "remove bad characters", or "only keep the good ones"?

    • Hint #2: You can use the String's charAt() method and ASCII values to identify characters

  • Test this method a few times before moving on to Part C

Note: You will not earn full credit if you simply call a standard method like "replaceAll." You must solve this using basic methods!

Part C - Palindrome

  • Write a recursive method to determine if the word is a palindrome

    • Hint #1: Start at the sides and work your way to the middle

    • Hint #2: You will have two base cases

Remember, this must be solved recursively. You can't just reverse the String.

Part D - Color

  • Your program must use output the "YES" message in green and the "NO" message in red.

  • Feel free to use colors in other ways throughout your program

  • Some example code is included in replit. But for more information, google around for "ANSI escape Codes"


Hello, welcome to the Palindrome Program.

Please enter a message ("q" to quit)

> aMaNa plan! a237^234 CaNaL231 Pan!aMa##()

The message "amanaplanacanalpanama" is a palindrome!

Please enter a message ("q" to quit)

> abcd

The message "abcd" is NOT a palindrome!

Please enter a message ("q" to quit)

> q