Monday 9 September 2013

simple pythagorean theorem calculator in ruby

simple pythagorean theorem calculator in ruby

I made a pythagorean theorem calculator in ruby and it has a bug/does not
run. The error is: undefined local variable or method `a2'. I Was
wandering if anyone could help. Thanks.
puts "Welcome to my pythagorean theorem calculator. This calculator can
find the hypotenuse of any right triangle. Please enter side A of your
triangle."
a = gets.to_f
puts "please enter side B of your triangle."
b = gets.to_f
a**2 == a2
b**2 == b2
a2 + b2 = a2_b2
puts "The hypotenuse of your triangle is: #{ Math.sqrt(a2_b2)}"

No comments:

Post a Comment