Write a program in java to find whether a number is neon or not.
Answers
Answered by
1
Answer:
this is question for computer chspter
Answered by
2
import java.util.Scanner;
public class NeonNumber {
public static void main(String[] args) {
int n,sq,sum = 0;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a number:");
n = scan.nextInt();
sq = n * n; //find square of the n
//calculating the sum of square
while(sq > 0)
{
sum = sum + sq % 10;
sq = sq / 10;
}
if(sum == n) //check sum and number
System.out.println(n+" is a neon number.");
else
System.out.println(n+" is not a neon number.");
}
}
When you run the program, the output will be following:
Enter a number: 1
1 is a neon number.
1
.
Similar questions
English,
6 months ago
Social Sciences,
6 months ago
Chemistry,
6 months ago
English,
1 year ago
Social Sciences,
1 year ago