program to find a whether number is neon or not by buffer method.
sdevesh668pdpwqg:
re mahakal gang ke sath aa rha hu
Answers
Answered by
0
. Use one while loop. This loop will exit only if user enters -1 as input number. Otherwise, get user input and check if it is ‘Neon’ or not for infinite time.
2. First take the input number from user.
3. Calculate the square of the number.
4. Now, find the sum of all the digits of the square number using a loop.
5. Finally, check if the sum is equal to the given number or not.
6. If equal, it is a Neon number. Else it is not.
2. First take the input number from user.
3. Calculate the square of the number.
4. Now, find the sum of all the digits of the square number using a loop.
5. Finally, check if the sum is equal to the given number or not.
6. If equal, it is a Neon number. Else it is not.
Answered by
1
ye lo..apna Program :)
import java.util.*;
public class NeonNumber
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the number to be checked.");
int num=ob.nextInt();
int square=num*num;
int sum=0;
while(square!=0)//Loop to find the sum of digits.
{
int a=square%10;
sum=sum+a;
square=square/10;
}
if(sum==num)
{
System.out.println(num+" is a Neon Number.");
}
else
{
System.out.println(num+" is not a Neon Number.");
}
}
}
import java.util.*;
public class NeonNumber
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the number to be checked.");
int num=ob.nextInt();
int square=num*num;
int sum=0;
while(square!=0)//Loop to find the sum of digits.
{
int a=square%10;
sum=sum+a;
square=square/10;
}
if(sum==num)
{
System.out.println(num+" is a Neon Number.");
}
else
{
System.out.println(num+" is not a Neon Number.");
}
}
}
Similar questions