Day 3: Intro to Conditional Statements HackerRank Solution


Day 3: Intro to Conditional Statements HackerRank Solution
Source : https://www.hackerrank.com/challenges/30-conditional-statements



Source : https://www.hackerrank.com/challenges/30-conditional-statements


Solution


// Karthikalapati.blogspot.com
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);
}
}

No comments:

Post a Comment