×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Perfect Numbers In Java - ICSE Examples Common Elements In Array In Java - ICSE Examples
Neon Numbers In Java - ICSE Examples - Java
9928    Arnab De    14/05/2018

Neon No In Java - ICSE Examples

A number is said to be neon, if sum of all digits of square of the number is equal to the number.
Input   9, It's square = 81 = 8+1 = 9       ( So 9 is a Neon Number )
Input   25, It's square = 625 = 6+2+5 = 13  ( So 25 is not a Neon Number )

Write a program to find and print neon numbers from different given numbers. this program should terminate / stop it's processing when a negetive number is given as input. Use "for loop" for finding the sum of digits and other process.

softetechnologies
import java.util.*;
class neonnumbers
{
    public static void main ()
    {
        Scanner sc = new Scanner (System.in);
        int no;
        for(; ;)
        {
          System.out.println("Enter the number:");
           no=sc.nextInt();
          if(no<0)
          {
              break;
            }
          int s=no*no,sum=0;
          for(;s>0;)
           {
            sum=sum+(s%10);
            s=s/10;
           }
          if(sum==no)
          {
              System.out.println("neon number");
          }
          else
          {
              System.out.println("not a neon number");
          }
        }
    }
}
softetechnologies

Output
==========

Enter the number:
23
not a neon number
Enter the number:
34
not a neon number
Enter the number:
9
neon number
Enter the number:
-1

Perfect Numbers In Java - ICSE Examples Common Elements In Array In Java - ICSE Examples
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
The supreme purpose and goal for human life... is to cultivate love.
Sri Sri Ramakrishna Paramahamsa
3342
72.84
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     51893
25/06/2018     43741
01/01/2018     42836
28/06/2017     40566
02/08/2017     39380
01/08/2017     33592
06/07/2017     33345
15/05/2017     32704
14/07/2017     28926
11/09/2018     28750
softetechnologies