For some reason this code always multiplies b
(2.54) by unit_number
, regardless of whether I put enter "cm" or "in":
puts "Welcome to my unit conversion calculator. This calculator can convert
between Centimeters and Inches. If you could like to convert Centimeters to Inches, write: in. If you would like to convert Inches to centimeters, write: cm."
unit = gets.to_s
puts " how many of your unit would you like to convert"
unit_number = gets.to_f
a = 0.39370079
b = 2.54
if unit == 'in'
puts "your conversion is: #{ (unit_number * a)}"
else unit == 'cm'
puts "your conversion is: #{ (unit_number * b)}"
end