Write a menu driven program using switch case in java for the following
To enter a number and find whether the number is 'Neon' or not. ( a number is said to be 'Neon',
if sum of the digits the square of the number is equal to the number itself.
Sample input:9
Answers
Answered by
2
Answer:
import java.util.Scanner;
public class NeonNumber
{
public static void main(String[] args)
{
int n,square,sum=0;
//create object of scanner.
Scanner sc = new Scanner(System.in);
//you have to enter number here.
System.out.print("Enter the number: " );
n=sc.nextInt();
//calculate square.
square=n*n;
while(square>0)
{
sum=sum+square%10;
square=square/10;
}
//condition for checking sum is equal or not.
if(sum==n)
System.out.println("Its a Neon number.");
else
System.out.println("Its not a Neon number.");
}
}
mark the answer as brainliest
Similar questions