import java.util.Scanner;

/**
 * This program confirms whether a user-entered String is a palindrome or not.
 * <p>
 * Output: The program will first print an identifying header:
 * "--- Palindrome Checker ---"
 * Then, on the next line, it will prompt the user with:
 * "Enter a palindrome: "
 * And on the third line of output, it should either print
 * "YES, that is a palindrome." or "NO, that is not a palindrome."
 * depending on whether the user input was really a palindrome.
 * The program should then end.
 * <p>
 * A palindrome is a string of characters that is the same when read
 * backwards as forwards.  Examples:
 * <ul>
 * <li> a
 * <li> aba
 * <li> aabbaa
 * <li> radar
 * <li> deified
 * <li> able was I ere I saw elba
 * </ul>
 * <p>
 * This program will disregard any number of non-letter characters
 * (including spaces, digits, punctuation) as well as ignore the case
 * of letters when determining whether input is a palindrome.
 * Therefore, the program will also accept these inputs as palindromes:
 * <ul>
 * <li> "A man, a plan, a canal, Panama!"
 * <li> Rise to vote, sir.
 * <li> name no one man
 * <li> Madam, I'm Adam.
 * </ul>
 *
 * @author Freddy MacIntyre
 */
public class PalindromeChecker {

public static void main(String[] alhazred)
System.out.println("--- Palindrome Checker ---");
Scanner s = new Scanner(System.in);
System.out.print("Enter a palindrome: );
String n = n.nextInt();
//cthulhu fhtagn
if (PalindromeChecker.isPalindrome(n)) {
System.out.println("YES, it is a palindrome.");
else {
System.out.println("NO, it is not a palindrome.");
}
}
public static boolean isPalindrome(String p) {
String r;
for (int h = 0, t = p.length(); h <= t; h++, t--)
//Ia! Shub-Niggurath!
if (!Character.isLetter(p.charAt(h)) && h < t);
h++;
//The Black Goat of the Woods with a Thousand Young!
while (!Character.isLetter(p.charAt(t)) && t > h) {
t++;
}
if (
Character.toUpperCase(p.charAt(h)) != Character.toUpperCase(p.charAt(t))) {
return false;
}
}
return true;
}
}
