Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Palindrome
- * Date : 25.05.19
- */
- import java.util.Scanner;
- public class Palindrom {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter number to check: ");
- int x = input.nextInt();
- if(palin(x)) System.out.println("The number is a Palindrom number.");
- else System.out.println("The number is not a Palindrom number.");
- input.close();
- }
- static boolean palin(int n) {
- int a = n, result = 0;
- while(a != 0) {
- int k = a % 10;
- result *= 10;
- result += k;
- a /= 10;
- }
- if(result == n) return true;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement