Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created October 26, 2010 20:38
Show Gist options
  • Save rjungemann/647755 to your computer and use it in GitHub Desktop.
Save rjungemann/647755 to your computer and use it in GitHub Desktop.
Converting pounds to kilos and vice versa in Ruby (for teaching purposes)
# 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