Showing posts with label neon-number. Show all posts
Showing posts with label neon-number. Show all posts

Monday, July 27, 2020

Write a program to input a number and check whether it is Neon Number or not?(9^2 = 81 , 8+1=9 , 9=9)

54)  Write a program to input a number and check whether it is Neon Number or not?(92 = 81 , 8+1=9 , 9=9)


import java.util.*;
public class Neon_number
{
    public static void main(String args[ ])
   {
          Scanner sc = new Scanner (System.in);
          System.out.println("Enter a number");
          int a = sc.nextInt();
          int s = 0;
          int p = a*a;
          while(p>0)
          {
          int d = p%10;
          s=s+d;
          p=p/10;
          }
          if(a==s)
          {
              System.out.println("Entered number is a NEON number ");
          }
          else
          {
              System.out.println("Entered number is not a NEON number ");
          }
   }
}

Output : 

 jhvghvgk ;nkjn ,nkjhj