java program to check neon number

Solutions on MaxInterview for java program to check neon number by the best coders in the world

showing results for - "java program to check neon number"
Iain
20 Jul 2018
1import java.util.Scanner;
2public class NeonNumberInJava
3{
4   public static void main(String[] args)
5   {
6      Scanner sc = new Scanner(System.in);
7      System.out.println("Please enter number to check neon number or not: ");
8      int number = sc.nextInt();
9      int square = number * number;
10      int sum = 0;
11      while(square != 0)
12      {
13         int n = square % 10;
14         sum = sum + n;
15         square = square / 10;
16      }
17      if(sum == number)
18      {
19         System.out.println(number + " is a neon number.");
20      }
21      else
22      {
23         System.out.println(number + " is not a neon number.");
24      }
25      sc.close();
26   }
27}