我开始制作货币转换器。这就是代码的样子:
print"What currency would you like to convert from?(british,yen):"
currency_in = gets.to_s
print"What currency would you like to convert to?(british,yen):"
currency_out = gets.to_s
print"How much would you like to convert?:"
to_c = gets.to_f
if (currency_in == "british") && (currency_out == "yen")
puts to_c * 181.69 + "Y"
elsif (currency_in == "yen") && (currency_out == "british")
puts to_c * 0.01
else
puts"no such currency"
end
但它没有像我期望的那样起作用。当我输入british
然后yen
或其他方式时,程序会继续"no such currency"
。