I've tried different approaches to do this, and when I do this..
import java.util.*;
public class Palindrome {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter number");
int number = in .nextInt();
int first = number
int middle = 0;
int last = first;
boolean isPalindrome = last == first;
if (isPalindrome) {
System.out.print("This is a palindrome");
} else
System.out.print("This is not a palindrome");
}
}
it spits out "this is a palindrome". Mind you I can't use loops. Shouldn't this work?
It works when I do this...
import java.util.*;
public class Palindrome {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter number");
int first = 1;
int middle = 0;
int last = 5;
boolean isPalindrome = last == first;
if (isPalindrome) {
System.out.print("This is a palindrome");
} else
System.out.print("This is not a palindrome");
}
}
It tells me if it's a palindrome or not... So, it works on my end, but not the users end.
What am I missing