Question: CODE Default.aspx Future Value Calculator 401K Future Value Calculator Monthly Investment: Annual interest rate: 3.0 Number of years: 10 Future Value: Default.aspx.cs using System; using
CODE
Default.aspx
401K Future Value Calculator
Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace XEx05FutureValue { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) for (int i = 50; i
protected void btnCalculate_Click(object sender, EventArgs e) { if (IsValid) { int monthlyInvestment = Convert.ToInt32(ddlMonthlyInvestment.SelectedValue); decimal yearlyInterestRate = Convert.ToDecimal(txtInterestRate.Text); int years = Convert.ToInt32(txtYears.Text);
decimal futureValue = this.CalculateFutureValue(monthlyInvestment, yearlyInterestRate, years);
lblFutureValue.Text = futureValue.ToString("c"); } }
protected decimal CalculateFutureValue(int monthlyInvestment, decimal yearlyInterestRate, int years) { int months = years * 12; decimal monthlyInterestRate = yearlyInterestRate / 12 / 100; decimal futureValue = 0; for (int i = 0; i
protected void btnClear_Click(object sender, EventArgs e) { ddlMonthlyInvestment.SelectedIndex = 0; txtInterestRate.Text = ""; txtYears.Text = ""; lblFutureValue.Text = ""; }
} }
visual studio c#
Open the application, set a breakpoint, and check the values in the loop
- Open the XEx05FutureValue application from blackboard.
- Set a breakpoint at the best point for determining the month number and future value each time through the loop.
- Run the application and record the future value after 1 month, 5 months, and 10 months. Note that the index variable for the loop provides the month number.
Use a tracepoint to monitor the values in the loop
- Convert the breakpoint that you set in step 2 to a tracepoint. Configure the tracepoint to output the value of the future value variable and the loop index variable. So, for example, the display for the first month should be something like this:
Month = 1 & value = 50.1250
- Now, run the application and then open the Output window. Find and record the future value after 1 month, 50 months, and 100 months. Now, imagine how cumbersome it would be to find these values with a regular breakpoint like in step 3!
- Stop the application and remove the tracepoint.
Use the Trace feature to monitor the values in the loop
- Enable the Trace feature for this application.
- Add a custom trace message to the application that displays the month number and future value each time through the loop. The display should look the same as the example in step 4.
- Now, run the application and then scroll to the trace output. Find and record the future value after 1 month, 10 months, and 50 months.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
