Created
October 1, 2013 15:40
-
-
Save geraudmathe/6780452 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
def compute operation, a, b | |
result = case operation | |
when 'a' | |
"#{a + b}" | |
when 's' | |
"#{a - b}" | |
when 'm' | |
"#{a * b}" | |
when 'd' | |
"#{a / b}" | |
end | |
puts result | |
end | |
def basic_calc | |
print "(a)dd, (s)ubtract, (m)ultiply, (d)ivide: " | |
operation = gets.chomp.downcase | |
print "first number: " | |
a = gets.to_f | |
print "second number: " | |
b = gets.to_f | |
compute(operation, a, b) | |
gets | |
end | |
basic_calc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment