Skip to main content
Participant
May 15, 2011
Answered

In need of help.

  • May 15, 2011
  • 4 replies
  • 483 views

I am making a simple annuity calculator and I am having trouble converting the annuity equation so it can be used in AS3.

I have spent the last hour and a half or so trying to convert this equation and I feel like an idiot. FVoa = PMT [((1 + i)n - 1) / i]

Here is my code below

var investment:Number
var interest:Number
var time:Number
var total:Number

button_btn.addEventListener(MouseEvent.CLICK, calculate)
function calculate(event:MouseEvent):void
{
    investment=Number(investment_txt.text)
    interest=Number(interest_txt.text)/100
    time=Number(time_txt.text)
    total=investment*(Math.pow(((1 + interest/12), time-1)/interest/12))
    total_txt.text=String(total)
}

And here is my stage if you want to see it.

http://oi52.tinypic.com/24enk35.jpg

When I try and run my program I get this error. "1084: Syntax error: expecting rightbrace before rightparen."

Edit: Added a missing parenthesis now I get this error "1136: Incorrect number of arguments.  Expected 2."

This topic has been closed for replies.
Correct answer kglad

:

total=investment*(Math.pow(1+interest/12,time)-1)/(interest/12);

4 replies

Participant
May 15, 2011

Thanks for the help guys  I got it to work.

kglad
Community Expert
Community Expert
May 15, 2011

actually, your formula looks wrong.  are you trying to create a "future value of investment" or a  "future value of investment on average" calculator?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 15, 2011

:

total=investment*(Math.pow(1+interest/12,time)-1)/(interest/12);

Ned Murphy
Legend
May 15, 2011

My shot at it says it should be...

total = investment * ((Math.pow(1+interest/12, time-1) - 1) / interest/12);

assuming n = time-1, and i = interest/12