Hi,
So here goes my story; I’m creating a online mortgage calculator but had no idea the equation for mortgages was so complicated.
this is the equation i’m using: [COLOR=#ff0000]a = ( p * r * ( 1 + r )n ) / ( ( 1 + r)n - 1 )[/COLOR]
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]p = [/COLOR][/SIZE][/FONT][/COLOR][COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the principal[/COLOR][/SIZE][/FONT][/COLOR]
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]a = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the payment per month[/COLOR][/SIZE][/FONT][/COLOR]
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]r = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the interest rate per month[/COLOR][/SIZE][/FONT][/COLOR]
[COLOR=#ff0000][FONT=Verdana, Arial][SIZE=2][COLOR=red]n = [/COLOR][/SIZE][/FONT][FONT=Verdana, Arial][SIZE=2][COLOR=darkgreen]is the number of months[/COLOR][/SIZE][/FONT][/COLOR]
I created 4 input boxes.
Instances names are:
- amount = principal
- years = for the number of years of the mortgage
- percentage = the interest rate per year
- total = obviously
here is my AS
calculate_btn.onRelease = function()
{
total.text = (Number(amount.text) * ((Number(percentage.text)/100)/12) * (1 + ((Number(percentage.text)/100)/12)).exp(Number(yeare.text)*12))/((1 + ((Number(percentage.text)/100)/12)).exp(Number(yeare.text)*12))-1;
}
the answer i get isn “NaN”
I’m really not that familiar with actionscript but this is what i came up with, I’m basically trying to get the answer with 2 decimal points of course
can someone tell me what i’m doing wrong
thanks in advance