WAP to take a 3 digit number as input check it is Palindrome number or not.
Eg:121 is a Palindrome number, if we reverse the number it will be same as original. ( JAVA PROGRAMMING )
PLS help me out !
Answers
Answer:
Your answer is in the attachment.
The first two photos are the program
The other three are output for three cases:
1. Number a palindrome and a three digit number
2. Number is not palindrome and a three digit number
3. Number is not a three digit number
Plzz mark as brainliest I made so much effort in writing this program.
Code:
import java.util.Scanner;
public class PalindromeNumber {
static boolean isPalindrome(int number) {
return new StringBuffer(number + "").reverse( ).toString( ).equals(number + "");
}
public static void main(String[ ] args) {
System.out.print("Enter a 3-digit number - ");
int number = new Scanner(System.in).nextInt( );
System.out.println((isPalindrome(number) ? "Is" : "Not") + " Palindrome");
}
}
Sample I/O:
Case 1:
Enter a 3-digit number - 123
Not Palindrome
Case 2:
Enter a 3-digit number - 121
Is Palindrome