Advertisement
minnera

#30daysofcode #day3

Sep 30th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. //https://www.hackerrank.com/challenges/30-conditional-statements/
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import java.text.*;
  6. import java.math.*;
  7. import java.util.regex.*;
  8. public class Solution {
  9.    
  10.    public static void main(String[] args) {
  11.       Scanner scan = new Scanner(System.in);
  12.       int n = scan.nextInt();
  13.       scan.close();
  14.       String ans="";
  15.          
  16.       // if 'n' is NOT evenly divisible by 2 (i.e.: n is odd)
  17.       if(n%2==1){
  18.          ans = "Weird";
  19.       }
  20.       else{
  21.          if(6 <= n && 20 >= n){
  22.             ans = "Weird";
  23.          }
  24.          else{
  25.             ans = "Not Weird";
  26.          }
  27.       }
  28.       System.out.println(ans);
  29.    }
  30. }
  31. /*
  32.     If is odd, print Weird
  33.     If is even and in the inclusive range of to , print Not Weird
  34.     If is even and in the inclusive range of to , print Weird
  35.     If is even and greater than , print Not Weird
  36. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement