SHARE
TWEET

Untitled

a guest Feb 16th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.text.DecimalFormat;
  3. import java.util.Arrays;
  4.  
  5. public class Main {
  6.  
  7.     public static void main (String [] args){
  8.         Scanner scanner = new Scanner(System.in);
  9.        
  10.         String command = "";
  11.         while (!command.equals("END")){
  12.             int input = Integer.parseInt(scanner.nextLine());
  13.             if (checkNumberIsPalindrome(input) == 1){
  14.                 System.out.println("true");
  15.             } else {
  16.                 System.out.println("false");
  17.             }
  18.         }
  19.     }
  20.    
  21.     public static int checkNumberIsPalindrome(int n){
  22.         int result = 0;
  23.        
  24.         String[] temp = Integer.toString(n).split("");
  25.         int[] arr = Arrays.stream(temp).mapToInt(Integer::parseInt).toArray();
  26.        
  27.         for (int i=0; i<arr.length; i++){
  28.             if (arr[i] == arr[arr.length-1-i]){
  29.                 result = 1;
  30.             } else {
  31.                 result = 0;
  32.             }
  33.         }
  34.         return result;
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top