forked from Krushna-Prasad-Sahoo/JavaCode-Hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPalindrome.java
23 lines (23 loc) · 817 Bytes
/
Palindrome.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.*;
public class PalindromeNumber
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("ENTER THE NUMBER");
int no = sc.nextInt();
int tempVar = no;
int sum = 0;
while(no > 0)
{
// reversing the number
sum = sum * 10;
sum = sum + (no % 10);
no = no / 10;
}
if(tempVar == sum)
System.out.print("The number " + tempVar +" is a palindrome number.");
else
System.out.print("The number " + tempVar +" is not a palindrome number.");
}
}