Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

6/25/2016

Day3:IntrotoConditionalStatements:Challenge|30DaysofCode|Tutorials|HackerRank

Practice

All Domains

Compete

Find Jobs

Rank

Leaderboard

Tutorials 30 Days of Code Day 3: Intro to Conditional Statements

Day 3: Intro to Conditional Statements


by aa1992

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

is odd, print Weird

If

is even and in the inclusive range of

to , print NotWeird

If

is even and in the inclusive range of

to

If

is even and greater than

, print Weird

, print NotWeird

Complete the stub code provided in your editor to print whether or not
Input Format

Connectingin...

is weird.
Reconnect

A single line containing a positive integer, .


Constraints

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

is odd and odd numbers are weird, so we print Weird .


Sample Case 1:
and

is even, so it isn't weird. Thus, we print NotWeird .

Submissions: 25172
Max Score: 30
Difficulty: Easy
More

Current Buffer saved locally, editable

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

Upload Code as File

Test against custom input

Run Code

Submit Code

Copyright 2016 HackerRank. All Rights Reserved

Join us on IRC at #hackerrank on freenode for hugs or bugs.


Contest Calendar | Blog | Scoring | Environment | FAQ | About Us | Support | Careers | Terms Of Service | Privacy Policy | Request a Feature

https://www.hackerrank.com/challenges/30conditionalstatements

2/2

You might also like