-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPalindrome.java
36 lines (32 loc) · 979 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
24
25
26
27
28
29
30
31
32
33
34
35
36
/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.Scanner;
public class Palindrome
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
if(isPalinDrome(number)){
System.out.println(number+" is PalinDrome");
}else{
System.out.println(number+" is not PalinDrome");
}
}
public static boolean isPalinDrome(int number){
int reminder,sum=0,temp;
temp=number;
while(temp>0){
reminder=temp%10;
sum=(sum*10)+reminder;
temp=temp/10;
}
if(number==sum){
return true;
}else{
return false;
}
}
}