我試圖通過gets.chomp添加用戶輸入的總成本,然後將其放回函數中,以便在函數結束時打印出總成本。我做對了嗎?如何將變量打印回我的函數?
def costs_of_company(hosting, design, phones, total_costs)
puts "Total costs are as follows: \n"
puts "Hosting costs $#{hosting}."
puts "Design would cost $#{design}."
puts "The cost for 100 Phones would be $#{phones}."
puts "Total costs are #{total_costs}"
end
puts "Tell me the costs of your company. \n"
puts "hosting \n"
hosting = gets.chomp
puts "design \n"
design = gets.chomp
puts "phones \n"
phones = gets.chomp
total_costs = hosting + design + phones #I think i am way off here.
costs_of_company(hosting, design, phones)
我相信你忘了在'total_costs'變量傳遞到costs_of_company'的'你的函數調用在最後一行 – Dbz