Question: Specification: A palindrome is a string that is the same when reversed. For example, abba is a palindrome. Here is a math-like definition: palindrome( )
Specification: A palindrome is a string that is the same when reversed. For example, "abba" is a palindrome. Here is a math-like definition: palindrome(" ") = true palindrome (x) = true palindrome (x + X + y) = false, if x ! = y = palindrome (X), if x = = y The symbol x stands for a single character, as does y. The symbol X stands for a string of characters. The symbol + stands for concatenation. In this version of palindrome every character must be matched. So punctuation and whitespace on one side of a string must match the same on the other. Also (for us) the case of a character must match. Implement palindrome () by following the above definition and write a main () that tests it public static boolean palindrome (String word) Design: Make this a console application, i e. a class that contains a static main that asks the user for a possible palindrome, reads in a complete line, and then uses palindrome () to test it. Write out the results. You only need to ask the user for one possible palindrome. Of course, palindrome () must be implemented recursively as above. Simple l/O is enough. You don't need to use Exceptions. You will need several methods of the String class. A run of the program: Enter a string: ABCBA That is a palindrome Another run: Enter a string: Radar That is NOT a palindrome Another run: Enter a string: able was I ere I saw elba That is a palindrome
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
