Jay
2013-02-28 17:37:54 UTC
public static void main(String[] args) {
while (true) {
display(check(retrieveInput()));
}
}
public static String retrieveInput() {
Scanner scan = new Scanner(System.in);
return scan.next();
}
public static boolean check(String input) {
boolean check = false;
try {
Integer.parseInt(input);
if (input.charAt(0)==input.charAt(4) && input.charAt(1)==input.charAt(3))
check = true;
} catch(Exception e) {
check = false;
}
return check;
}
public static void display(boolean check) {
if(check) System.out.println("Is a five-digit palindrome.");
else System.out.println("Is not a five-digit palindrome.");
It works but I don't know how to integrate an array. Please help!