Skip to content

Instantly share code, notes, and snippets.

Created July 24, 2017 04:07
Show Gist options
  • Save anonymous/c9be991c5a480d3ce605c0f89e74ef45 to your computer and use it in GitHub Desktop.
Save anonymous/c9be991c5a480d3ce605c0f89e74ef45 to your computer and use it in GitHub Desktop.
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"?
@rab
Copy link

rab commented Jul 24, 2017

what about "exit" or "quit" or "Quit"? Or even just a Ctrl-D for the unix-fluent among us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment