public class PalindromeInteger {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Please write an integer value");
int num=input.nextInt();
System.out.println(isPalindrome(num));
System.out.println("Reverse number is= "+reverse(num));
}
public static int reverse(int number){
int x=number%10;
int y=number/10;
int z=y%10;
int c=y/10;
int v=c%10;
int newNumber=x*100+z*10+c;
return newNumber;
}
public static boolean isPalindrome(int number)
{
int newNumber=reverse(number);
if(number==newNumber){
System.out.println("Number is Palindrome");
}else
System.out.println("It is not Palindrome number");
return true ;
}
}
Hiç yorum yok:
Yorum Gönder