-
-
Save mariiaKolokolova/2203e9969fc679b11c63e1a078abcfbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package maricka.kolokolova; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Please, input your six-digit number to check is it palindrome or not:"); | |
int num; | |
int check; | |
num = sc.nextInt(); | |
check = num / 100000; | |
if (check < 1 || check > 9) { | |
System.out.println("Your number is not correct. Please input one more time."); | |
} else { | |
int n1; | |
int n2; | |
int n3; | |
int n4; | |
int n5; | |
int n6; | |
n1 = num / 100000; | |
n2 = num / 10000 % 10; | |
n3 = num / 1000 % 10; | |
n4 = num / 100 % 10; | |
n5 = num / 10 % 10; | |
n6 = num % 10; | |
if ((n1 == n6) & (n2 == n5) & (n3 == n4)) { | |
System.out.println("Your number is palindrome"); | |
} else { | |
System.out.println("Your number is not palindrome"); | |
} | |
} | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment