sontek (sontek) wrote in visualbasic,
sontek
sontek
visualbasic

algorithm

S(n)/(1 - (1 + r)^-n)


I'm writing this loan code and thats the equation that has to be calculate.. I just don't understand how I would do it. Math is a struggle for me. p = rSn(subscript n) / 1 - (1 + r)-n (to the negative n or something like that)

http://www.sontek.net/equ.jpg is a picture of what the equation looks like.


I'm doing the code in Visual Basic.. I have everything setup I just don't know how to setup the equation in the code (I don't know that much math so that equation makes no sense to me at all)

p - is an equal periodic (monthly) payment
r - is interest rate stated as an annual interest rate
n - is the number of monthly payments over the life of the loan
Sn - is the amount of the loan




This is what I tried doing.. But its overflowing.. so if anyone has any ideas let me know

answer = ammount * (number) / (1 - (1 + interest) ^ number)
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 3 comments
Ok I layed that algorithm out wrong for some reason... Dunno how its supposed to be.. but heres what I'm supposed to do. www.sontek.net/task.txt
firstly, if S(n)/(1 - (1 + r)^-n) is an accurate representation of the equation you're modelling then instead of:
answer = amount * (number) / (1 - (1 + interest) ^ number)
you should be using:
answer = amount * (number) / (1 - (1 + interest) ^ -number)

you should probably also make sure that you're using the double floating-point datatype as otherwise higher-order exponentiations tend to result in either 0 or NaN results.
I am trying to write a similar program as the one you posted here. Except it is a loan calculator with a down payment, interest rate and years invested.

I believe the formula for this is:

for counter=1 to term
balance= principle * (1+interest) ^ counter
lstoutput.additem ("whatever you want to print
out")

but not sure. I am a newbie and trying to pick up things on my own, but it is not working out too well.

I have a listbox I want to show the results in. The downpayment is a txt box and the pther two combo boxes. Any suggestions?