import java.util.Scanner;
public class Ex3 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Please input a word: ");
String Line = keyboard.nextLine();
boolean x = isReverse(Line);
System.out.print("It is " + x + " that this word is a palindrome.");
}
public static boolean isReverse(String Line) {
int length = Line.length();
boolean x = true;
String s = "";
for (int i = 0; i < length; i++) {
if (Line.charAt(i) != ' ') {
s += Line.charAt(i);
}
}
for (int i = 0; i < length; i++) {
if (Line.charAt(i) != Line.charAt(length - 1 -i)) {
x = false;
}
}
return x;
}
}
What I am trying to do is make a program that takes a word or phrase as input and returns true or false depending on if it is a palindrome or not. In the program I am supposed to ignore whitespace and punctuation marks and make palindromes such as "A man, a plan, a canal, Panama." I think I have solved the whitespace problem, but can not figure out how to ignore all punctuation marks.