Skip to content

Instantly share code, notes, and snippets.

@siakaramalegos
Created January 20, 2016 16:40
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 siakaramalegos/7a890bbeb5ad509483c7 to your computer and use it in GitHub Desktop.
Save siakaramalegos/7a890bbeb5ad509483c7 to your computer and use it in GitHub Desktop.
Imperial to Metric program
# Defining my methods at the top so I can use them later
# Ask user for their name
def get_name
puts "Hellooo there, what is your name?"
gets.chomp
end
# Ask the user for their height in inches
def get_height_inches(user_name)
puts "Hi, " + user_name + ", what is your height in inches?"
print "Enter height > "
gets.chomp.to_i
end
# Convert inches to cm
def inches_to_cm(height_inches)
height_inches * 2.54
end
# Give them their height in cm
def output_height_cm(height_cm)
puts "Your height in cm is " + height_cm.to_s
end
# Calling my methods to run the program
user_name = get_name
height_inches = get_height_inches(user_name)
height_cm = inches_to_cm(height_inches)
output_height_cm(height_cm)
# Calling my methods to run the program
user_name = get_name
height_inches = get_height_inches(user_name)
height_cm = inches_to_cm(height_inches)
output_height_cm(height_cm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment