我想制作这个简单的程序,通过选择单位来返回重量。当我运行该程序时,它运行没有任何问题,并在if
中询问两个问题,但没有返回value
这是我的代码:
puts "What is your starting weight and ratio unit?
1:kg.m/h
2:gm.m/s
3:mm.m/s"
inputing_unit = gets.chomp
puts "What is your ending weight and ratio unit?
1:kg.m/h
2:gm.m/s
3:mm.m/s"
ending_unit = gets.chomp
if inputing_unit == 1 and ending_unit == 1 then
puts "What is your weight?"
input_weight = gets.chomp.to_i
puts "What is your ratio?"
input_ratio = gets.chomp.to_i
puts "Your moving value is #{input weight * input_ratio}"
end
答案 0 :(得分:1)
正如我在前一行描述开头的截图中看到的那样,你的puts语句中有一个拼写错误#{input weight * input_ratio}
。您应该将...#{input weight...
更改为...#{input_weight...
(使用短划线)。