Question: import java.util.Scanner; public class PalindromeTest { // Create a method named is Palindrome using Recursion // Given any input string, is Palindrome () evaluates whether

import java.util.Scanner; public class PalindromeTest { // Create a method named is Palindrome using Recursion // Given any input string, is Palindrome () evaluates whether the string is a palindrome // The method should return true if the input string is a palindrome and // return false if the input string is not a palindrome. public static void main (String[] args) { String str; Scanner kbs = new Scanner(System.in); System.out.println("This program will test whether a string entered is a palindrome!"); System.out.println( System.out.print ("Please enter a string : "); str = kbs.nextLine(); // Remove white spaces & punctuation marks, and convert all letters to upper case str = str.replaceAll("[^A-Za-z]+", "").toUpperCase(); System.out.println("Current String : " + str); // Use is Palindrome method to detect whether str is a palindrome } // end of main } // end of class In the provided template, the following statement str = str.replaceAll("[^A-Za-z]+", "").toUpperCase(); handles the pre-processing step by using regular expression to remove any white spaces and punctuation marks in the string. The remaining alphabets will be converted to upper case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
