Question: Currently, I have a program where it tells you if it is a palindrome but doesn't account for spaces and punctuation. I figured I could

 Currently, I have a program where it tells you if it

Currently, I have a program where it tells you if it is a palindrome but doesn't account for spaces and punctuation. I figured I could call a sperate method to filter the string before passing it into the testPalindrome method. How could a separate method filter out the string beforehand? if not, what would be a better option?

is a palindrome but doesn't account for spaces and punctuation. I figured

I could call a sperate method to filter the string before passing

A palindrome is a string that is spelled the same way forward and backward. Some examples of palindromes are "radar", able was i ere i saw elba", and (if spaces are ignored) "a man a plan a canal panama." Write a recursive method testPalindrome that returns boolean value true if the string stored in an array is a palindrome and false otherwise. The method should ignore spaces and punctuation in the string. (Hint: String method tocharArray gets a char array containing the String's characters.] public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner (System.in); String Pal; String Pal2; System.out.println("Please eneter palindrome"); Pal = input.nextLine(); palFilter(Pal); Pal2 = Pal; if( test Palindrome (Pal)== true) { System.out.println("Your word is a plaindrome"); else System.out.println("Your word is not a plaindrome"); public static boolean testPalindromeString Ball if( Pal == null) { return false; if (Pal.length()==1) return true; String fchar = Pal.substring (0,1); String lchar = Pal.substring (Pal.length()-1, Pal.length()); if(!fchar.equals(lchar)) return false; else return test Palindrome (Pal.substring(1, Pal.length()-1)); public static String palFilter(String Pal) { return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!