-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindrome.java
More file actions
28 lines (26 loc) · 872 Bytes
/
Palindrome.java
File metadata and controls
28 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//System.out.println("Enter a word or any string:");
//String word = scan.nextLine();//input string
System.out.println("Enter a number:");
int num = scan.nextInt();//input number
int reverse=0;
int num1 = num;
while(num1!= 0){
int digit = num1 % 10;
num1 = num1 / 10;
reverse = reverse*10 + digit;
}
scan.close();
System.out.println(num);
System.out.println(reverse);
if(num == reverse){
System.out.println("THE ENTERED NUMBER IS A PALINDROME!");
}
else{
System.out.println("number is not palindrome..");
}
}
}