Java If-Else ⬀
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:
Source: Wikipedia
Given an integer, n, perform the following conditional actions:
- If
nis odd, printWeird - If
nis even and in the inclusive range of2to6, printNot Weird - If
nis even and in the inclusive range of6to20, printWeird - If
nis even and greater than20, printNot Weird
Complete the stub code provided in your editor to print whether or not n is weird.
A single line containing a positive integer, n.
1 ≤n ≤100
Print Weird if the number is weird; otherwise, print Not Weird.
3
Weird
24
Not Weird
n is odd and odd numbers are weird, so we print Weird.
n > 20 and n is even, so it isn't weird. Thus, we print Not Weird.
