Skip to content

Latest commit

 

History

History

Java If Else

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Java HackerRank

Difficulty Max Score Success Ratio
Easy 10 91.38%

In this challenge, we test your knowledge of using if-else conditional statements to automate decision-making processes. An if-else statement has the following logical flow:

Wikipedia if-else flow chart

Source: Wikipedia

Task

Given an integer, [SVG image] , perform the following conditional actions:

  • If [SVG image] is odd, print Weird
  • If [SVG image] is even and in the inclusive range of [SVG image] to [SVG image] , print Not Weird
  • If [SVG image] is even and in the inclusive range of [SVG image] to [SVG image] , print Weird
  • If [SVG image] is even and greater than [SVG image] , print Not Weird

Complete the stub code provided in your editor to print whether or not [SVG image] is weird.

Input Format

A single line containing a positive integer, [SVG image] .

Constraints

  • [SVG image] Output Format

Print Weird if the number is weird; otherwise, print Not Weird.

Sample Input 0

3

Sample Output 0

Weird

Sample Input 1

24

Sample Output 1

Not Weird

Explanation

Sample Case 0: [SVG image]

[SVG image] is odd and odd numbers are weird, so we print Weird.

Sample Case 1: [SVG image]

[SVG image] and [SVG image] is even, so it isn't weird. Thus, we print Not Weird.

💡 Hints

➡️ Approach

✅ Detailed Solution

View Solution : Java If-Else

Submissions Leaderboard Discussions Editorial
📝 My Submission 🏆 Track our position 🤔 Help from Community ✍️ Editorial