| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Investment Calculator - need it to calculate properly. Please check my syntax.
I created an investment calculation form in Microsoft Visual Studio 2003, designed to post as a form on the web. When it posts to the web, the user should be able to:
1)Put in ANY amount in the initial investment box (say, 200, just as an example) 2)Put in ANY expected annual rate of return (say, 8%, just as an example) 3)Put in ANY number of years (say, 6, just as an example) 4)Press the CALCULATE the FUTURE VALUE button. Once the user presses the CALCULATE the FUTURE VALUE button, he should see a two-column table, underneath the form, which shows a (compounded annually) running total (in this example, 6 years): Year 1 $216 Year 2 $233.28 Year 3 $251.9424 Year 4 $272.097792 Year 5 $293.86561536 Year 6 $317.3748645888 Here's my original code. I can't get it to compound annually from Year 1 on, as described above. (It shows Years 1 through 6 as all $216. That's WRONG. Year 2 should compute $233.28, Year 3 should compute $251.94, and so on.) In addition, I'm having trouble creating the two-column table. Col 1 should show the number of years. Col 2 Should show a dollar sign, followed by the running total per year. In addition, the final year and respective amount should be in BOLD. Please correct and flesh out my syntax where necessary. Thanks for your expertise! I really appreciate it! :-} __________________________________________________ ______________________________________ <% DIM counter, initialinvestment, annualrateofreturn, numberofyears, investmentvalue initialinvestment = request.form ("initial investment") response.write ("Initial investment is:" & initialinvestment & "<br/>") annualrateofreturn = request.form ("annual rate of return") response.write ("Annual rate of return is:" & annualrateofreturn & "<br/>") numberofyears = request.form ("number of years") response.write ("Number of years:" & numberofyears & "<br/>") investmentvalue = initialinvestment*(1 + annualrateofreturn) for counter = 1 to numberofyears response.write(counter&" " & "<br/>") investmentvalue = initialinvestment*(1 + annualrateofreturn/100) 'percents will be inserted as (for example)8%, not 0.08 response.write (investmentvalue&" " &"<br/>") next %> <form method = "post" action= "InvestmentCalc.asp"> <h3>Investment Calculator</h3> <b>Initial Investment:</b <input type= "text" name= "initial investment" value='<%= initialinvestment%>'/><br/> <b>Expected Annual Rate of Return %:</b> <input type="text" name="annual rate of return" size = "10" maxlength = "10" value="<%= annualrateofreturn%>"/><br/> <b>Number of Years:</b> <input type="text" name="number of years" size = "3" maxlength = "3" value="<% =numberofyears%>"/></p> <input type="submit" value="Calculate the Future Value"/></p> </form> 'The two-column table should appear here' </body> </html> |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Investment Calculator - need it to calculate properly. Please check my syntax. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|