我用 Ruby 制作了一个勾股定理计算器,它有一个错误/无法运行。错误是:
undefined local variable or method `a2'
我想知道是否有人可以提供帮助。
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)}"