Hackerrank - Java Solution - Java If-Else - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, December 12, 2017

Hackerrank - Java Solution - Java If-Else

Hackerrank - Java Solution - Java If-Else

HackerRank Problem Solution

Problem Name - Java If-Else
Problem Link -  https://www.hackerrank.com/challenges/java-if-else/problem
Level - Introduction Challenges

Java Code
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        /* Read input */
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        scan.close();
        
        /* Determine answer */
        String ans = "";
        if (n % 2 == 1) {
            ans = "Weird";
        } else {
            if (n >= 6 && n <= 20) {
                ans = "Weird";
            } else {
                ans = "Not Weird";
            }
        }
        
        /* Print output */
        System.out.println(ans);
    }
}


Tags: HackerRank Online Judge Solution, HackerRank OJ Solution list, HackerRank Problems Solution, HackerRank solver, HackerRank all problem solution list, HackerRank solution in java, Hackerrank Java Solution, Hackerrank - Java Solution - Java If-Else

No comments:

Post a Comment