Skip to content

Instantly share code, notes, and snippets.

@kangkyu
Created October 22, 2014 02:17
Show Gist options
  • Save kangkyu/30d1cfccb1ab2e706321 to your computer and use it in GitHub Desktop.
Save kangkyu/30d1cfccb1ab2e706321 to your computer and use it in GitHub Desktop.
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