Tuesday, July 28, 2020

Write a program to input a number and check whether it is Super Palindrome Number or not?(11 is a palindrome and also its square is palindrome ,so it is super palindrome)

57)  Write a program to input a number and check whether it is Super Palindrome Number or not?(11 is a palindrome and also its square is palindrome ,so it is super palindrome)


import java.util.*; 
public class Super_Palindrome
{
    public static void main(String args[ ])
   {
              Scanner sc = new Scanner (System.in);
              System.out.println("Enter a number");
              int a = sc.nextInt();
              int k = a;
              int r = 0;
              while(k>0)
              {
              int d = k%10;
              r=(r*10)+d;
              k=k/10;
              }
              if(r==a)
              {
                  int m = a*a;
                  int y = 0;
                  while(m>0)
                  {
                        int d = m%10;
                        y=(y*10)+d;
                        m=m/10;
                  }
                  if(y==(a*a))
                  {
                      System.out.println("Entered number is a SUPER PALINDROME Number ");
                  }
                  else
                  {
                      System.out.println("Entered number is not a SUPER PALINDROME Number ");
                  }
              }
              else
              {
                  System.out.println("Entered number is not a SUPER PALINDROME Number ");
              }
   }
}

Output : 


No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj