Advertisement
LDDestroier

(schoolwork) business math 8.6

Mar 12th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local nprompt = function(prompt)
  2.     print(prompt)
  3.     term.clearLine()
  4.     term.setTextColor(colors.yellow)
  5.     write("> ")
  6.     term.setTextColor(colors.white)
  7.     return tonumber(read())
  8. end
  9.  
  10. local amountFinanced = nprompt("Amount financed?")
  11. local months = nprompt("Months?")
  12. local monthlyPayment = nprompt("Monthly payment?")
  13.  
  14.  
  15. local function getFinanceCharge(months, monthlyPayment, amountFinanced)
  16.     local totalPaybackAmount = monthlyPayment * months
  17.     local financeCharge = totalPaybackAmount - amountFinanced
  18.     local financeChargePerHundred = 100 * (financeCharge / amountFinanced)
  19.     return totalPaybackAmount, financeCharge, financeChargePerHundred
  20. end
  21.  
  22. totalPaybackAmount, financeCharge, financeChargePerHundred = getFinanceCharge(months, monthlyPayment, amountFinanced)
  23.  
  24. print("Look for '"..tostring(financeChargePerHundred).."'")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement