Problem Statement
A description of the problem can be found on Hackerrank.
Solution
I created solution in:
All solutions are also available on my GitHub.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import java.util.*; public class JavaIfElse { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String ans = ""; if(n % 2 == 1) { ans = "Weird"; } else { if(n >= 2 && n <= 5) { ans = "Not Weird"; } else if(n >= 6 && n <= 20) { ans = "Weird"; } else { ans = "Not Weird"; } } System.out.println(ans); } } |