Given an integer as input, can you check the following:
- If is odd then print "Weird"
- If is even and, in between range 2 and 5(inclusive), print "Not Weird"
- If is even and, in between range 6 and 20(inclusive), print "Weird"
- If is even and , print "Not Weird"
Input Format
Single line of input: integer .
Constraints
Output Format
Print "Weird" if the number is weird; else, not "Not Weird" without the quotes.
Sample Input 1
3
Sample Output 1
Weird
Sample Input 2
24
Sample Output 2
Not Weird
Solution:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int i = in.nextInt();
if(i>=1&&i<=100){// Checking condition of 1<=N<=100
if(!(i%2==0))//Checking if N is odd printing Weird.
{
System.out.println("Weird");
}
else if(i%2==0){
if((i>=2&&i<=5)||i>20)
System.out.println("Not Weird");
if(i>=6&&i<=20)
System.out.println("Weird");
}
}
}
}