Day 3: Intro to Conditional Statements | 30 Days of Coding | HackerRank | Java Language

**Before watching this make sure that you’ve tried enough**
Language: Java 7

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) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt(); 
      scan.close();
      String ans="";
          
      // if 'n' is NOT evenly divisible by 2 (i.e.: n is odd)
      if(n%2==1){
         ans = "Weird";
      }
      else{
         if(n>=2 && n<=5)ans = "Not Weird";
          else if(n>=6 && n<=20)ans = "Weird";
             else if(n>20)ans = "Not Weird";
      }
      System.out.println(ans);
   }
}

 

If this solution helped you, please share this with your friends.
And if you have anything to say, let me know in the comment section.
More solutions are coming so Like our Facebook page and Subscribe to our YouTube channel to stay connected.

Leave a Comment