0% found this document useful (0 votes)
34 views

If-Else: Weird Not Weird Weird Not Weird

This document discusses using if-else conditional statements in Java to determine whether a positive integer is weird or not. It provides sample inputs of 3 and 24 and the corresponding outputs of "Weird" and "Not Weird" based on the rules that (1) odd numbers are weird, (2) even numbers in the range of 2 to 5 or from 20 to 100 are weird, and (3) other even numbers are not weird. The task is to complete stub code to print the determination for a given positive integer input.

Uploaded by

Abhishek Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

If-Else: Weird Not Weird Weird Not Weird

This document discusses using if-else conditional statements in Java to determine whether a positive integer is weird or not. It provides sample inputs of 3 and 24 and the corresponding outputs of "Weird" and "Not Weird" based on the rules that (1) odd numbers are weird, (2) even numbers in the range of 2 to 5 or from 20 to 100 are weird, and (3) other even numbers are not weird. The task is to complete stub code to print the determination for a given positive integer input.

Uploaded by

Abhishek Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

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 Not Weird

If is even and in the inclusive range of to , print Weird

If is even and greater than , print Not Weird

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

Input Format

A single line containing a positive integer, .

Constraints

Output Format

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

Sample Input 0

Sample Output 0

Weird

Sample Input 1
24

Sample Output 1

Not Weird

Explanation

Sample Case 0:
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 Not Weird .

You might also like