Jump to content

Loan/Payment Functions


DexterMorgan
 Share

Recommended Posts

I have no idea if someone did this before, but I was learning this at school, and decided to make one with autoit. Im going to create a whole GUI and even the NPER formula and make a whole thing with it for a project.

;// PMT EXAMPLE (How much you will pay per Month)
$loanamount = 20000; Initial Loan Amount$20,000
$apr = 0.12 ;percent interest per year, NOT PER MONTH!
$months = 15; How long until you pay all of it off
$pmt = pmt($apr,$months,$loanamount);; payment per month
msgbox(0,"Your Payment Per Month","If you pay "&$apr*100&"% APR, for "&$months&" months, on a $"&$loanamount&" loan, you will have to pay $"&$pmt[0]&" every month."&@CRLF&"This will end up costing you $"&$pmt[1]&" in interest costing you a total of $"&$pmt[2])

;// PV EXAMPLE (How much of a Loan you can Afford)
$pmt = 1442.475604; How much you can afford to pay per month
$apr = 0.12 ;percent interest per year, NOT PER MONTH!
$months = 15; How long do you want this loan
$pv = pv($apr,$months,$pmt);; payment per month
msgbox(0,"You can Afford","If you can pay $"&$pmt&" every month for "&$months&" months, at "&$apr*100&"% interest, you can afford a $"&$pv&" loan!")

func pmt($apr,$months,$pv)
$rate = $apr/12
$pmt1 = Round(abs($pv/((1-(1/(1+$rate)^$months))/$rate)),2)
$totalpayment = round($pmt1*$months,2)
$totalinterest = round($totalpayment - $pv,2)
local $pmt[3] = [$pmt1,$totalinterest,$totalpayment]
return $pmt
EndFunc

func pv($apr,$months,$pmt)
$rate = $apr/12
return round(ABS($pmt*((1-(1+$rate)^-$months)/$rate)),2)
EndFunc

Those are the 2 formulas with examples

If you dont understand something just by the code, if you run it it should make more sense. Or else just let me know ill explain it

Edited by DexterMorgan
code
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...