#--------------------------------------------------------------------------
# ● 输入变量
#--------------------------------------------------------------------------
first_count = 34
second_count = 28.67
symbol = "-"
#--------------------------------------------------------------------------
# ● 计算过程
#--------------------------------------------------------------------------
def results(first_count, second_count, symbol)
case symbol
when '+' then result = first_count + second_count
when '-' then result = first_count - second_count
when '*' then result = first_count * second_count
when '/' then result = first_count / second_count
when '%' then result = first_count % second_count
when '**' then result = first_count ** second_count
else
print "ERROR!!!"
return
end
print "#{first_count} #{symbol} #{second_count} = #{result}"
end
#--------------------------------------------------------------------------
# ● 输出结果
#--------------------------------------------------------------------------
results(first_count, second_count, symbol)[/pre]