2017-07-25 5 views
0

単位を選択して重量を返すこの簡単なプログラムを作成します。私はプログラムを実行すると、それは問題なく動作し、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

コードの画像ではありません。 –

+0

show show your code ... –

+1

私は遅れて申し訳ありません。 –

答えて

1

私は最初にそのスクリーンショットから見ることができるようにあなたのputsステートメントはどこですか?最後の行の説明には、タイプ#{input weight * input_ratio}があります。 ...#{input weight......#{input_weight...(ダッシュ記号付き)に変更する必要があります。

+0

まだ最初の2つの質問だけを求めています。 –

+3

整数への型変換が間に合わないと思います。あなたのifステートメントは 'inputing_unit.to_i == 1かつending_unit.to_i == 1なら' –

+0

のように始まります。それはうまくいきましたman:D –

関連する問題