Question: JAVA: Write a program WordPalindromeTest.java which invokes a method named is WordPalindrome to test whether your input String is a word palindrome. Follow these steps:
JAVA: Write a program WordPalindromeTest.java which invokes a method named isWordPalindrome to test whether your input String is a word palindrome. Follow these steps:
1. Read a line from the console, pass the line read (i.e. string) to the method isWordPalindrom which should return trueor false accordingly.
2. The method should begin by converting the passed string to all lower-case and then also remove any character which is: not a digit, not a letter, and not white space (note we need to keep the white space to do the split in the next step)
3. Convert the string into an array of Strings (i.e. each entry in the array is a single word of the original string).
4. Adapt your algorithm from the first problem to test for equality of arrays of Strings instead of individual Strings.
5. Print out the array of words (this will help with debugging), and then your answer;
6. Demonstrate your code on the poem shown above:
Note: You will have to enter this poem in a single line to avoid the newlines. In eclipse you can also do so as follows using backslashes, a typical way of indicating line breaks in a poem when putting it all in one line:
Spoken Breath / Creating flesh and spirit / Spirit and flesh creating / Breath spoken.
Also test your program on the following sentence:
This is not a word palindrome!
**Another Word Palindrome: Life- imitates nature, always moving, traveling continuously. Continuously traveling, moving always, nature imitates life.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
