次のエラーが発生します。
/calcTax.rb:9: syntax error, unexpected $undefined
grandtotal = $#{subtotal - tax}
このコードから:
print('What amount would you like to calculate tax for? $')
subtotal = gets.to_i
taxrate = 0.078
tax = subtotal * taxrate
if (tax > 0.0)
grandtotal = $#{subtotal + tax}
else if (tax < 0.0)
grandtotal = $#{subtotal - tax}
puts "Tax on $#{subtotal} is $#{tax}, so the grandtotal is $#{grandtotal}."
subtotal
別の方法で値を設定する必要があるのか、それともプログラムを修復するために何ができるのか疑問に思っています。
10行目でもunexpected $end
エラーが発生しています。