
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Java Program to Check whether the input number is a Neon Number
In this article, we will understand how to check whether the input number is a neon number. A neon number is such a number whose sum of digits of square of the number is equal to the number.
Below is a demonstration of the same −
Input
Suppose our input is −
9
Output
The desired output would be the following because 92 = 81 i.e. 8 + 1 = 9
The given input is a neon number
Algorithm
Step1- Start Step 2- Declare an integers my_input Step 3- Prompt the user to enter an integer value/ Hardcode the integer Step 4- Read the values Step 5- Compute the square of the input and store it in a variable input_square Step 6- Compute the sum of the of the digits of input_square and compare the result with my_input Step 6- If the input matches, then the input number is a neon number Step 7- If not, the input is not a neon number. Step 8- Display the result Step 9- Stop
Example 1
Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool .
import java.util.Scanner; public class NeonNumbers{ public static void main(String[] args){ int my_input, input_square, sum=0; Scanner my_scanner = new Scanner(System.in); System.out.println("Required packages have been imported"); System.out.println("A scanner object has been defined "); System.out.println("Enter the number: "); my_input=my_scanner.nextInt(); input_square=my_input*my_input; while(input_square>0){ sum=sum+input_square%10; input_square=input_square/10; } if(sum!=my_input) System.out.println("The given input is not a Neon number."); else System.out.println("The given input is Neon number."); } }
Output
Required packages have been imported A scanner object has been defined Enter the number: 9 The given input is Neon number.
Example 2
Here, the integer has been previously defined, and its value is accessed and displayed on the console.
public class NeonNumbers{ public static void main(String[] args){ int my_input, input_square, sum=0; my_input= 9; System.out.printf("The number is %d ", my_input); input_square=my_input*my_input; while(input_square<0){ sum=sum+input_square%10; input_square=input_square/10; } if(sum!=my_input) System.out.println("\nThe given input is not a Neon number."); else System.out.println("\nThe given input is Neon number."); } }
Output
The number is 9 The given input is Neon number.
- Related Articles
- Swift Program to Check whether the input number is a Neon Number
- Haskell Program to Check whether the input number is a Neon Number
- How to check whether the input number is a Neon Number in Golang?
- Haskell program to check whether the input number is a Prime number
- Haskell Program To Check Whether The Input Number Is A Palindrome
- Java program to check whether the given number is an Armstrong number
- Java Program to Check Whether a Number is Even or Odd
- Java Program to Check Whether a Number is Positive or Negative
- Java Program to Check Whether a Number is Prime or Not
- Program to check whether a number is Proth number or not in C++
- How to Check Whether a Number is Krishnamurthy Number or Not in Java?
- How To Check Whether a Number is Strontio Number or Not in Java?
- How To Check Whether a Number is Tcefrep Number or Not in Java?
- How To Check Whether a Number is Tech Number or Not in Java?
- Check Whether a Number is a Coprime Number or Not in Java

Advertisements