Created
October 22, 2014 02:17
-
-
Save kangkyu/30d1cfccb1ab2e706321 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
print "the first number: " | |
a = gets.chomp | |
print "operator: " | |
operator = gets.chomp | |
print "the second number: " | |
b = gets.chomp | |
answer = case operator.ord | |
when 43 then a.to_i + b.to_i | |
when 45 then a.to_i - b.to_i | |
when 42 then a.to_i * b.to_i | |
when 47 then a.to_f / b.to_f | |
else | |
"error" | |
end | |
puts "answer: #{answer}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment