So i am a college student and my assignment is to create a code that determines if an entered number is a palindrome or not.
the assignment is as follows:
"Write the following two methods:
//Return the reversal of an integer, i.e. revers(456) returns 654
public static int reverse(int number)
//Return true if number is palindrome
public static boolean isPalindrome(int number)
Use the reverse method to implement isPalindrome. a number is a palindrome if its reversal is the same as itself. write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome."
here is my attempt at the code. i know its missing a lot of things but i am truly and completely stuck. thanks for all the help in advance guys.
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
// Display name
System.out.println("Programmed by ");
// Get number from human
Scanner input = new Scanner(System.in);
System.out.print("Please enter a number: ");
int digit = input.nextInt();
// Define variables
int d = digit;
int rev = 0;
int i = reverse(digit);
int j = isPalindrome(digit);
// Create reverse method
public static int reverse(int digit){
int r;
for (int x = 0; x <= digit; x++)
r = digit%10;
digit = digit/10;
rev = rev * 10 + r;
}
// Create isPalindrome method
public static boolean isPalindrome(int digit){
}
}
}