-
Create a file named
height_to_centimeters.rb -
Store your name and height (in inches) into variables.
-
Concatenate those variables into a sentence and have it print to the screen.
-
For example: Shane is 60 inches tall
-
Once complete, add in a weight variable:
- Make the program interactive
- Ask the user for input on:
- name
- height
- weight
- Store that input in a variable
-
Create variables that will convert the data to the metric system
-
To get height in centimeters multiply the your previous height variable by 2.54
-
To get weight in Kilograms multiply the weight variable by 0.453592
weight_kilograms = weight_pounds * 0.453592
-
Print the new data to the terminal
my_name = 'John Smith'
height_inches = 60
puts my_name + " is " +
height_inches.to_s + " inches tall."weight_pounds = 160puts "Hi! what's your name?"
my_name = gets.chomp
puts "How tall are you (in inches)?
height_inches = gets.chomp
puts "If you don't mind me asking,
how much do you weight?
weight_pounds = gets.chomp
puts "#{my_name} is #{height_inches}
inches tall and weighs #{weight_pounds}"height_centimeters = height_inches * 2.54puts "{my_name} is #{height_centimeters} cm
and #{weight_kilograms} kg"puts "Hi! what's your name?"
my_name = gets.chomp
puts "How tall are you (in inches)?"
height_inches = gets.chomp.to_f
puts "If you don't mind me asking,
how much do you weight?"
weight_pounds = gets.chomp.to_f
height_centimeters = height_inches * 2.54
weight_kilograms = weight_pounds * 0.453592
puts "#{my_name} is #{height_centimeters} cm and #{weight_kilograms} kg"