Computer Science, asked by ShanayaTrivedi, 1 year ago


Write a Program in Java to input a number and check whether it is an Evil Number or not. An Evil number is a positive whole number which has even number of 1’s in its binary equivalent.

Answers

Answered by saurav01234567890
3
Ok so first let me tell you what's an Evil number is U can skip this if you know what is an Evil number.

Evil Number : An Evil number is a positive whole number which has even number of 1’s in its binary equivalent.

And now I'll give you an example to your question.....
Example: Binary equivalent of 9 is 1001, which contains even number of 1’s.
A few evil numbers are 3, 5, 6, 9….

Design a program to accept a positive whole number and find the binary equivalent of the number and count the number of 1’s in it and display whether it is a Evil number or not with an appropriate message. Output the result in format given below:

Example 1
INPUT : 15
BINARY EQUIVALENT : 1111
NO. OF 1’s : 4
OUTPUT : EVIL NUMBER

Example 2
INPUT : 26
BINARY EQUIVALENT : 11010
NO. OF 1’s : 3
OUTPUT : NOT AN EVIL NUMBER


HAPPY PROGRAMMING !
(No one is happy doing programming XD :p)



Anjula: Nice !
saurav01234567890: :)
ShanayaTrivedi: Thankyou very much for helping me saurav
saurav01234567890: U r wlcm! :)
Answered by choudhary21
2
\color{Black}{ \boxed{\bold{ \underline{Hii. Frd .Your .Answer}}}}

 <b>

 \huge {GOOD... MORNING}}

{\mathbb{CORRECT...ANSWER}}



{\mathbb{EVIL NUMBER}} - An Evil number is a positive whole number which has even number of 1’s in its binary equivalent.

{\mathbb{EXAMPLE}} - Binary equivalent of 9 is 1001 which contains even number of 1’s.

A few evil numbers are 3, 5, 6, 9….


Example 1
INPUT : 15
BINARY EQUIVALENT : 1111
NO. OF 1’s : 4
OUTPUT : EVIL NUMBER

Example 2
INPUT : 26
BINARY EQUIVALENT : 11010
NO. OF 1’s : 3
OUTPUT : NOT AN EVIL NUMBER



\color{orange}{ \boxed{\bold{ \underline{ i .Hope .Help .You .jiiii}}}}

Anjula: Cool
ShanayaTrivedi: Thankyou..very much. More than the explanation, the decoration was nice
Anjula: @Choudary u have given many answers thats great ...keep it up ! One day u will shine in brainly and get a nice rank :) hoping for all the best ! From ur sister-Anjula :D
Similar questions