Advertisement
LoraOrliGeo

24

Aug 29th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task24 {
  4. public static void main(String[] args) {
  5.  
  6. Scanner sc = new Scanner(System.in);
  7.  
  8. String number = sc.nextLine();
  9. int index = 0;
  10.  
  11. boolean isPalindrome = true;
  12.  
  13. do {
  14. if (number.charAt(index) != number.charAt(number.length() - index - 1)) {
  15. isPalindrome = false;
  16. break;
  17. }
  18.  
  19. index++;
  20. } while (index < number.length() / 2);
  21.  
  22. if (isPalindrome) {
  23. System.out.println("The number is palindrome");
  24. } else {
  25. System.out.println("The number is not palindrome");
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement