Computer Science, asked by Anonymous, 1 year ago

program to find a whether number is neon or not by buffer method.


sdevesh668pdpwqg: re mahakal gang ke sath aa rha hu
sdevesh668pdpwqg: tere gand marne
sdevesh668pdpwqg: aa rha hu

Answers

Answered by ankit4021
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.

 


ankit4021: is it correct
ankit4021: ...
ankit4021: oh
ankit4021: sorry
ankit4021: hmmm
ankit4021: why
Answered by sdevesh668pdpwqg
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.");
        }
    }
}

sdevesh668pdpwqg: puch rha tha..koe bf hai tumhara
sdevesh668pdpwqg: ???
ankit4021: areq
sdevesh668pdpwqg: wahh
sdevesh668pdpwqg: haha :D
sdevesh668pdpwqg: ..
sdevesh668pdpwqg: bye
sdevesh668pdpwqg: :)
Similar questions