Created
October 26, 2010 20:38
-
-
Save rjungemann/647755 to your computer and use it in GitHub Desktop.
Converting pounds to kilos and vice versa in Ruby (for teaching purposes)
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
# formulas to convert between kilos and pounds | |
def pounds_to_kilos pounds | |
pounds * 0.45359237 | |
end | |
def kilos_to_pounds kilos | |
kilos / 0.45359237 | |
end | |
# print some examples to the screen | |
puts "120 pounds in kilos is " + pounds_to_kilos(120).to_s | |
puts "120 kilos in pounds is " + kilos_to_pounds(120).to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment