Description
The purpose of this challenge is to use if, nested ifs and while statements while using basic comparison operators
Requirements
- Use a while loop. As long as the user doesn’t enter a zero, perform the following:
- 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”
- ADDITIONALLY, if the number is divisible by 5, display a message “The number is divisible by 5”
- Remember, continue asking for input until the user enters a zero. When the user enters a zero, your while loop will terminate. Then, display a message “OK, we’re done here”
Sample Interaction / Output
Enter a number: -5 The number is negative 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 Enter a number: 0 OK, we're done here
LEGEND
PROGRAM OUTPUT
USER ENTRY
CATALOG ID: CPP-FLOW0005
Print Requirements