Description
The purpose of this challenge is to use if, else-ifs or nested ifs while using basic comparison operators
Requirements
- Display a message that asks the user to pick a number (negative numbers are ok)
- If the number entered is 404, display a message “Not found”
- If the number entered is 411, display a message “You can’t handle the information!”
- Note that in (3) and (4) above, you have to specifically handle each case separately.
- If the entered number is neither 404 nor 411, then do the following
- If the number is negative, display a message “The number is negative”
- If the number is divisible by 2, display a message “The number is even” otherwise display a message “The number is odd” (HINT: Use the modulus operator–the % operator–to detect even or odd numbers. Understand that % operator returns the integer remainder of A % B. If A % 2 == 0, then A is an even number — an even number is divisible by 2. Otherwise, A is an odd number)
- ADDITIONALLY, if the number is divisible by 5, display a message “The number is divisible by 5”
Sample Interaction / Output
Enter a number: -5
The number is negative
The number is odd
The number is divisible by 5
Enter a number: 411
You can't handle the information
Enter a number: 5
The number is odd
The number is divisible by 5
Enter a number: 404
Not found
Enter a number: 8
The number is even
Enter a number: 10
The number is even
The number is divisible by 5
Enter a number: 3
The number is odd
LEGEND
PROGRAM OUTPUT
USER ENTRY
CATALOG ID: CPP-FLOW0001D
Print Requirements