Professional Documents
Culture Documents
Day 3 - Intro To Conditional Statements - Challenge - 30 Days of Code - Tutorials - HackerRank
Day 3 - Intro To Conditional Statements - Challenge - 30 Days of Code - Tutorials - HackerRank
Day3:IntrotoConditionalStatements:Challenge|30DaysofCode|Tutorials|HackerRank
Practice
All Domains
Compete
Find Jobs
Rank
Leaderboard
Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial
Objective
In this challenge, we're getting started with conditional statements. Check out the Tutorial tab for learning materials and an instructional video!
Task
Given an integer, , perform the following conditional actions:
If
If
to , print NotWeird
If
to
If
, print Weird
, print NotWeird
Complete the stub code provided in your editor to print whether or not
Input Format
Connectingin...
is weird.
Reconnect
Output Format
Print Weird if the number is weird; otherwise, print NotWeird .
Sample Input 0
3
Sample Output 0
Weird
Sample Input 1
24
Sample Output 1
NotWeird
Explanation
Sample Case 0:
https://www.hackerrank.com/challenges/30conditionalstatements
1/2
6/25/2016
Day3:IntrotoConditionalStatements:Challenge|30DaysofCode|Tutorials|HackerRank
Submissions: 25172
Max Score: 30
Difficulty: Easy
More
Java 8
7 importjava.io.*;
8 importjava.util.*;
9 importjava.text.*;
10 importjava.math.*;
11 importjava.util.regex.*;
12 publicclassSolution{
13
14 publicstaticvoidmain(String[]args){
15 Scannerscan=newScanner(System.in);
16 intn=scan.nextInt();
17 scan.close();
18 Stringans="";
19
20 //if'n'isNOTevenlydivisibleby2(i.e.:nisodd)
21 if(n%2==1){
22 ans="Weird";
23 }
24 else{
Connectingin...
25 //Completethecode
26 }
27 System.out.println(ans);
28 }
29 }
30
Reconnect
Line:1Col:1
Run Code
Submit Code
https://www.hackerrank.com/challenges/30conditionalstatements
2/2