hacker rank java 3rd question solution
3.Java If-Else
import java.util.Scanner;
public class Solution
{
public static void main(String[] args) {
Scanner sn =new Scanner(System.in);
int a=sn.nextInt();
if(a%2!=0){
System.out.println("Weird");
}
if(a%2==0 && a>1 && a<=5){
System.out.println("Not Weird");
}else if(a%2==0 && a>5 && a<=20){
System.out.println("Weird");
}
else if(a%2==0 && a>20){
System.out.println("Not Weird");
}
}
}
Comments