Created
March 7, 2013 08:13
-
-
Save jkaihsu/5106377 to your computer and use it in GitHub Desktop.
Define four methods which correspond to the four basic arithmetic operations: add, subtract, multiply, divide.They should accept either integers or floating point numbers as input. divide should perform floating point division.
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
| def add(x,y) | |
| x + y | |
| end | |
| def subtract(x,y) | |
| x - y | |
| end | |
| def multiply(x,y) | |
| x * y | |
| end | |
| def divide(x,y) | |
| x.to_f / y.to_f | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! I have spent hours trying to solve this with actual integers, whoops:)