Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package bluucat;
  2.  
  3. public class bluupalindromeonline {
  4.  
  5.     public static void main(String[] args) {
  6.    
  7.     }
  8.     public static boolean isPalindrome(int n) {
  9.  
  10.         System.out.println("What number do you wanna check?");
  11.  
  12.     //  Scanner input = new Scanner(System.in);
  13.         int remainder, sum = 0, temp;
  14.         // n = input.nextInt();
  15.         // input.nextLine();
  16.  
  17.         temp = n;
  18.  
  19.         while (n > 0) {
  20.             remainder = n % 10;
  21.  
  22.             sum = (sum * 10) + remainder;
  23.             n = n / 10;
  24.         }
  25.         if (temp == sum) {
  26.             System.out.println("number is palindrome");
  27.             return true;
  28.  
  29.         } else {
  30.             System.out.println("number not palindrome");
  31.           return false;
  32.         }
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement