出于某种原因,无论我输入“cm”还是“in”,这段代码总是乘以b
(2.54) :unit_number
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