0
我寫了一個程序。Ruby數學計算器程序
print "Radius = "
radius = gets.chomp
print "Height = "
height = gets.chomp
ans = (2 * 3.14 * (radius * radius)) + (2 * 3.14 * radius * height)
它不起作用。這是在終端輸出("11"
和"10"
是什麼,我把爲圓柱的半徑/高):
Radius = 11
Height = 10
in `*': can't convert String into Integer (TypeError)
請幫助。
「無法將字符串轉換爲整數」強烈建議您**需要將「半徑」和「高度」轉換爲數字。 – 2013-04-23 00:51:13