as homework I am to write two methods; one that is a reversal method using public static int(int number) while the other is a Palindrome method using public static boolean isPalindrome(int number). I've been working on this for a couple hours and am honestly stumped. I'm not asking for my homework to be done for me, just help in understanding where to go from here. Thanks. My current code is as follows;
public class Exercise
{
public static void main(String[] args)
{
System.out.println("Please enter an integer. ");
Scanner input = new Scanner(System.in);
int number = input.nextInt();
boolean Final = isPalindrome(number);
System.out.println(Final);
}
public static int reverse(int number)
{ // missing return?
int y;
int n;
for (n = 0; n <= number; n++)
{ // parameters
y = number % 10; // remainder
number = number / 10; // gets rid of last digit
n = n * 10 + y; // sets reverse values
return n; // returns reversed number
}
}
public static boolean isPalindrome(int number)
{
int n = reverse(number); // call reverse method
boolean result; // declare result
if (n = number)
{ // incompatible types?
result = true;
System.out.println("The number " + number + " is a " + "Palindrome" + ".");
}
else if (n != number)
{
result = false;
System.out.println("The number " + number + " is a Palindrome" + ".");
}
return result; // not initialized?
}
}