Math, asked by zoya318, 9 months ago

Write a program in java to find whether a number is neon or not.

Answers

Answered by 3325
1

Answer:

this is question for computer chspter

Answered by dheeraj4290
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