Sunday, January 6, 2019

How to check Palindrome Number

How to check Palindrome Number


Learn:
1. check the given number is Palindrome or not.
2. write different test cases




Code:



package Questions;

public class PalindromeNumber {
//151 454 34543 161 78987  
//teet
public static void isPalindromeNumber(int num){
System.out.println("Given Number is :" + num);
int r=0;
int sum=0;
int t;
t=num;
while(num>0){
r = num%10; //get the remainder
sum = (sum*10)+r;
num=num/10;
}
if(t==sum){
System.out.println("palindrome number");
}else{
System.out.println("not palindrome number");
}
}

public static void main(String[] args) {
isPalindromeNumber(151);
isPalindromeNumber(152);
isPalindromeNumber(78987);
isPalindromeNumber(1110);
isPalindromeNumber(0);


}



}





2 comments:

Featured Post

Advanced Selenium Webdriver Interview Questions and Answers in Java

Advanced Selenium Webdriver Interview Questions and Answers in Java Selenium WebDriver - QA Here is the list of Selenium Inte...