Created
October 20, 2015 15:38
-
-
Save siakaramalegos/8aaa2cd77c64ff772a85 to your computer and use it in GitHub Desktop.
Imperial to metric ruby program
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
# Imperial to Metric conversion program | |
puts "*************************************************" | |
puts "*** Welcome to My Fancy Conversion Program! ***" | |
puts "*************************************************\n\n" | |
puts "What's your name?" | |
user = gets.chomp | |
puts "\nWhat is your height in inches?" | |
user_height_inches = gets.chomp.to_i | |
puts "\nAren't you a tall glass of water? What's your weight in pounds?" | |
user_weight_lbs = gets.chomp.to_i | |
def convert_inches_to_cm inches | |
# Conversion factors | |
inches_to_cm = 2.54 | |
# Calculation | |
inches * inches_to_cm | |
end | |
def convert_lbs_to_kg pounds | |
# Conversion factors | |
lbs_to_kg = 0.45 | |
# Calculation | |
pounds * lbs_to_kg | |
end | |
height_cm = convert_inches_to_cm(user_height_inches) | |
weight_lbs = convert_lbs_to_kg(user_weight_lbs) | |
puts "\nHi, #{user}! Your height in cm is #{height_cm} and your weight in kg is #{weight_lbs}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment