Ultrashock Forums > Flash > ActionScript > UltraMath
Finance Calculator

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Finance Calculator
Old 2005-09-15

Hi

I'm trying to do a finance calculator in flash. Quite a simple application, but I have no PMT function (as you get in excel), so I need the PMT function, but can't find it anywhere.

It's for a car site, to work out what the user can afford as total price for a vehicle. There are some fixed amounts, which just gets added to the amount I'm trying to work out.

I've got the following functions from another site:

function rate(principal, periods, payment) {
myrate = 0;
increment = 0.1;
decimals = 0
while(pmt(principal,myrate,periods) != payment && decimals < 9) {
while(pmt(principal, myrate, periods) < payment) {
myrate = myrate+increment;
}
myrate = myrate-increment;
increment = increment/10;
decimals++;
}
myrate = math.round(myrate*100000000)/100000000;
return myrate;
}

function pmt(principal, rate, periods) {
if(rate == 0) {
mypayment = principal/periods;
} else {
mypayment = principal*(rate/12) / (1-1/math.pow(1+rate/12,periods));
}
return mypayment;
}

I just can't seem to work out the principal, which I think is the value I'm after. Would be grateful if anyone can have a look at this and give me the formula/function for working out the principal.

Regards
MtraX
http://mtrax.iuma.com - play
http://www.webdesignsouthafrica.co.za - work
postbit arrow 3 comments | 319 views postbit arrow Reply: with Quote   
Registered User
MtraX is offline
seperator
Posts: 8
2002-07-23
Age: 33
seperator

Ultrashock Member Comments:
Andy M's Avatar Andy M Andy M is offline Super Moderator Andy M lives in Canada 2005-09-15 #2 Old  
P = (PV*IR) / (1 - (1 + IR)^(-N))


P = payment (per period)
PV = present value of money (principal)
IR = interest rate
N = number of payments or periods



I think you're after the P (monthly payment). PV is the amount owing for the vehicle. So for example, a $25,000 with $10,000 will have $15,000 remaining.

That's equivalent to taking out a $15,000 loan. If it's paid monthly with a 3% interest rate (IR = 0.03/12) over a 2 year period (24 pay periods), then you'll have a monthly payment of $644.72 or $15473.28 after 2 years (24 x $644.72).

In that case, you can use a modified formula:

P = ((PV-DP)*IR) / (1 - (1 + IR)^(-N))


P = payment (per period)
PV = present value of car
DP = down payment
IR = interest rate (remember to divide this by 12 if monthly!)
N = number of payments or periods

or for total price with a loan:

TP = (((PV-DP)*IR) / (1 - (1 + IR)^(-N)))*N
Reply With Quote  
MtraX MtraX is offline 2005-09-19 #3 Old  
Hi

Thanx a bunch. Will report back if I run into problems.

Regards
MtraX
Reply With Quote  
Andy M's Avatar Andy M Andy M is offline Super Moderator Andy M lives in Canada 2005-09-20 #4 Old  
No problem. That's what US is for. Glad I could help.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: