Palindrome Program
Description
The program inputs a string and uses a recursive method to determine whether or not it is a palindrome.For example, "Race car" and "Step on no pets!" are palindromes.
The program should remove blank spaces and punctuations from the input string.
Associated Concepts:
Recursion
Algorithm:
main method:
isPalindrome method definition:
Input a string
Convert the input string to uppercase letters
Remove the blank spaces and punctuations in the input string
Call isPalindrome method with the input string as the argument and use a boolean variable flag to hold the returned value
If flag is true
Yes
Otherwise
No
Convert the input string to uppercase letters
Remove the blank spaces and punctuations in the input string
Call isPalindrome method with the input string as the argument and use a boolean variable flag to hold the returned value
If flag is true
Yes
Otherwise
No
isPalindrome method definition:
If the input string has only one character or is empty, return true.
Otherwise, compare the first element and the last element.
Otherwise, compare the first element and the last element.
If they are equal, call isPalindrome method recursively on the substring
from the second element to the second to the last element.
Otherwise, return false.
Otherwise, return false.