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");
}
}
}


Compiler Message
Success
Input (stdin) 
3
Expected Output
Weird

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions