public class Palindrome { public static void main (String [] args) {
EasyReader console = new EasyReader (); int input, dig1, dig2, dig3,dig4, dig5;
System.out.println("Enter a five digit number: "); input = console.readInt();
while(input > 99999 || input < 10000) { System.out.println("Entry is invalid due to an incorrect number of digits."); System.out.print("Entry is invalid due to an incorrect number of digits."); input = console.readInt(); }
dig1 = input / 10000; // Checks each digit to make sure for a palindrome dig2 = (input % 10000) / 1000; dig4 = (input % 10000) % 1000) / 10; dig5 = (input % 10000) % 1000) % 10;
System.out.println(" " + input + " is a palindrome.");
I'm using Emacs to run and compile this just an fyi, but the dig5 math statement won't tab over and i'm not sure why. I have easyreader in the file and checked my semi-colons. It's really starting to aggravate me and my teacher said we will have one simiallr to this tomarrow for the test.
Oh yeah and a palindrome is a number that reads backwards and forwards. i.e 12321, 45654, and so on. The math should be correct but feel free to check me on that as well.