Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created April 28, 2020 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariiaKolokolova/2203e9969fc679b11c63e1a078abcfbf to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/2203e9969fc679b11c63e1a078abcfbf to your computer and use it in GitHub Desktop.
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