Skip to content

Instantly share code, notes, and snippets.

/test

Created January 26, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5150d074a7e53b3f950c to your computer and use it in GitHub Desktop.
Save anonymous/5150d074a7e53b3f950c to your computer and use it in GitHub Desktop.
test
def add(a, b)
puts "ADDING #{a} + #{b}"
return a + b
end
def subtract(a, b)
puts "SUBTRACTING #{a} - #{b}"
return a - b
end
def multiply(a, b)
puts "MULTIPLYING #{a} * #{b}"
return a * b
end
def divide(a, b)
puts "DIVIDING #{a} / #{b}"
end
puts "Let's do some math with just functions!"
age = add(30, 5)
height = subtract(78, 4)
weight = multiply(90, 2)
iq = divide(100, 2)
puts "Age: #{age}, Height: #{height}, Weight: #{weight}, IQ: #{iq}"
# A puzzle for the extra credit, type in anyway
puts "Here is a puzzle."
what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
puts "That becomes: #{what}. Can you do it by hand?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment