Calculator Help

1. Senior Member
Join Date
Dec 1969
Posts
1,388

## Calculator Help

Does anyone have any sample code I could work from that would resemble the calculator at <BR><BR>http://www.northwesternmutual.com/nmcom/NM/calculatorform/toolbox--calculator--howmuchworthresults--calculator_muchworth<BR><BR>All I really need to know how to do is the subtraction of the second interest rate in a loop. I know how to compound it, I just need to subtract it compounded correctly.. anyone have any information?<BR><BR>Thank you so much,<BR><BR>Matt

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## I don't understand the question...

Why are you SUBTRACTING *anything*???<BR><BR>Or do you mean in order to print out the balances in the account on a yearly basis as it is paid down? Anyway, to create the amounts, it&#039;s all addition, no subtracting.<BR><BR>Here...this was enough fun I created a page:<BR><BR>******** savingsDemo.asp *********<BR>&lt;HTML&#062;&lt;BODY&#062;<BR><BR>& lt;FORM&#062;<BR>&lt;BR&#062;Age: &lt;INPUT Name=age&#062;<BR>&lt;BR&#062;Retire at: &lt;INPUT Name=retire&#062;<BR>&lt;BR&#062;Current pay: &lt;INPUT Name=pay&#062;<BR>&lt;BR&#062;-- enter next two values as percentages (but no % sign) --<BR>&lt;BR&#062;Expected average annual pay raise &lt;INPUT Name=payraiseRate&#062;<BR>&lt;BR&#062;Expected average savings earning rate &lt;INPUT Name=savingsRate&#062;<BR>&lt;BR&#062;&lt;INPUT TYPE=Submit Name=Submit Value=Submit&#062;<BR>&lt;/FORM&#062;<BR><BR>&lt;%<BR>If Request("Submit") = "Submit" Then<BR><BR>curPay = Request("Pay")<BR>srate = Request("savingsRate")<BR>prate = Request("payraiseRate")<BR>age = Request("age")<BR>retire = Request("retire")<BR><BR>acct = 0<BR>sum = 0<BR><BR>pay = curPay<BR><BR>savingsFactor = 1 + (srate/100) &#039; 1 plus the interest rate<BR>payFactor = 1 + (prate/100) &#039; 1 plus expected raise rate<BR>For yr = age to retire-1<BR>&nbsp; &nbsp; Response.Write "At age " & yr & ", you will be paid " & FormatCurrency(pay) & "&lt;BR&#062;"<BR>&nbsp; &nbsp; sum = sum + pay<BR>&nbsp; &nbsp; acct = acct + ( pay / ( savingsFactor ^ (yr-age) ) )<BR>&nbsp; &nbsp; pay = pay * payFactor<BR>Next<BR>Response.Write "&lt;HR&#062;You will have earned " & FormatCurrency(sum) & "&lt;BR&#062;" <BR>Response.Write "That&#039;s equivalent to " & FormatCurrency(acct) & " in savings&lt;HR&#062;"<BR><BR>&#039; now go the other way, to prove it:<BR>Response.Write "If you had saved that amount, it would be paid thus:&lt;P&#062;"<BR>pay = curPay<BR>For yr = age to retire-1<BR>&nbsp; &nbsp; acct = acct - pay<BR>&nbsp; &nbsp; Response.Write "At age " & yr & " you&#039;d be paid " & FormatCurrency(pay) _<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; & ", your balance=" & FormatCurrency(acct)<BR>&nbsp; &nbsp; acct = acct * savingsFactor<BR>&nbsp; &nbsp; Response.Write ", and after interest=" & FormatCurrency(acct) & "&lt;BR&#062;"<BR>&nbsp; &nbsp; pay = pay * payFactor<BR>Next<BR><BR>End If<BR>%&#062;<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
1,388

## RE: I don't understand the question...

Thank you so much for that code - I was just heading the wrong direction due to my mathmatical inabilities.. :) <BR><BR>Thanks so much once again!!!<BR><BR><BR>Matt

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•