Created
July 24, 2017 04:07
-
-
Save anonymous/c9be991c5a480d3ce605c0f89e74ef45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompt = "--> " | |
def test_user_input(number) | |
if number.even? | |
puts "" | |
puts "'#{number}' is an EVEN number." | |
puts "" | |
else | |
puts "" | |
puts "'#{number}' is an odd number." | |
puts "" | |
end | |
end | |
puts "" | |
puts "Please enter a number, odd or even." | |
puts "" | |
print prompt | |
number = gets.chomp.to_i | |
test_user_input(number) | |
# What would I need to add to make this keep cycling through asking user for another number to test until they type "Exit"? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what about "exit" or "quit" or "Quit"? Or even just a Ctrl-D for the unix-fluent among us?