A Neon Number is a positive integer, which is equal to the sum of the digits of its square.
For example, 9 is a neon number, because 92 = 81, and the sum of the digits 8 + 1 = 9, which is same as the original number.
Write a program in Java to input a positive integer from the user, and check if that number is a Neon Number.
import java.io.*;
class Neon{
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("N = ");
int n = Math.abs(Integer.parseInt(br.readLine()));
int s = n * n;
int sum = 0;
while(s != 0){
int d = s % 10;
sum += d;
s /= 10;
}
if(n == sum)
System.out.println(n + " is a Neon Number.");
else
System.out.println(n + " is not a Neon Number.");
}
}