Hackerrank – Java Solution – Java If-Else

Hackerrank - Java Solutions Hackerrank Online Judge Solution

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

Leave a Reply

Your email address will not be published. Required fields are marked *