Solve this program:
Write a Java program to input a number:
1.Check whether the number is palindrome or not.
2. Whether it is a perfect number or not.
Answers
Answered by
2
public brainly
class Palindrome
{
public static void main(String[] args)
{
int num = 11221, reversedInteger = 0,
remainder, originalInteger; originalInteger = num;
// reversed integer is stored in variable for
( ;num != 0; num /= 10 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder; } /
/ palindrome if orignalInteger and reversedInteger are equal if (originalInteger ==
reversedInteger)
System.out.println(originalInteger +
" is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome."); } }
class Palindrome
{
public static void main(String[] args)
{
int num = 11221, reversedInteger = 0,
remainder, originalInteger; originalInteger = num;
// reversed integer is stored in variable for
( ;num != 0; num /= 10 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder; } /
/ palindrome if orignalInteger and reversedInteger are equal if (originalInteger ==
reversedInteger)
System.out.println(originalInteger +
" is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome."); } }
Similar questions