Answers for "neon number program in java"

1

Java program to check neon number

import java.util.Scanner;
public class NeonNumberInJava
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter number to check neon number or not: ");
      int number = sc.nextInt();
      int square = number * number;
      int sum = 0;
      while(square != 0)
      {
         int n = square % 10;
         sum = sum + n;
         square = square / 10;
      }
      if(sum == number)
      {
         System.out.println(number + " is a neon number.");
      }
      else
      {
         System.out.println(number + " is not a neon number.");
      }
      sc.close();
   }
}
Posted by: Guest on October-30-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language