Error message - help please

Here is the code

puts “How heavy are you in stones?”

stones = gets.chomp

puts “Enter any pounds”

pounds = gets.chomp

kilos_stone = stones * 16 / 2.20

kilos_pound = pounds / 2.20

puts “So you weigh #{kilos_stone + kilos_pound} kilos”
and here is the erros

I cannot figure out what I have done wrong - can anyone help please?

stones is a string, and you can’t divide strings by floats. You need to convert it to a number first, try stones.to_i or stones.to_f.

Great, thanks - I changed the stones = gets.chomp to stones = gets.chomp.to_f and that worked

1 Like