write a menu driven program to check whether a number is evil number or not.9use switch case statement)
Answers
class CheckEvenOddSwitch{
public static void main (String args[]){
//int num1=100;
int num2=111;
switch(num2%2){//this will return 1
case 0:
System.out.println(num1+" is a Even number");
break;
case 1:
System.out.println(num2+" is a Odd number");
}
}
//Note: It's a java program
Answer:
Evil Number
An evil number is a non-negative number that has an even number of 1s in its binary expansion. (Binary Expansion – is representation of a number in the binary numeral system or base-2 numeral system which represents numeric values using two different symbols: typically 0 (zero) and 1 (one)).
Odious Numbers: Numbers that are not Evil are called Odious Numbers. Given a number, the task is to check if it is Evil Number or Odious Numbers.
Examples :
Input : 3
Output : Evil Number
Explanation: Binary expansion of 3 is 11,
the number of 1s in this is 2
Input : 16
Output : Odious Number(not an evil number)
Explanation: Binary expansion of 16 = 10000,
having number of 1s =1 i.e odd.
Input : 23
Output : Evil Number
Explanation: Binary expansion of 23 is 10111,
the number of 1s in this is 4 i.e