Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

I dont know whay method is not working?

#IMC , Calculation of the corporal index of a person, then print it on the screen.
#We need to ask our costumer about the high(meters) and weight(kilograms)
puts "Hello , Welcome to Body mass index with ruby"
puts "Please write your first your weight in Kg , and them hight"
a=gets
b=gets
def imb(a,b)
  return a/(b**2)
end
puts imb(a,b)

Can someone help tell why the last line is not working?.(I put the numbers but nothing ,after it shows like there is a mistake...I dont get any result from the method imb example a=5 and b=41

2 Answers

You would have to convert the user input into integers like this:

a = gets.to_i
b = gets.to_i

On another note, are you sure this is how you calculate BMI?

Thanks Maciej

what happen if I have floats? , because the value of person hight can be 1.43m, the result may be floats too..

If you want floats use .to_f instead.

thanks again Maciej