I am trying to figure out what's the best way how I can set up a conditional expression using a breakpoint to determine the month and futureValue values in a for loop. I already set up the breakpoint, but I just don't know how I can set up conditions properly. In my web application, after I have set up the breakpoint, I show be able to see index (month) and futureValue of that month right? Here is my C# code and in it you will that the statement " futureValue= (futureValue ) .... " is the executable statement that I would like my breakpoint to be at.
- 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 <= 500; i += 50)
- ddlMonthlyInvestment.Items.Add(i.ToString());
- }
-
- 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 < months; i++)
- {
- futureValue = (futureValue + monthlyInvestment)
- * (1 + monthlyInterestRate);
- }
- return futureValue;
- }
-
- protected void btnClear_Click(object sender, EventArgs e)
- {
- ddlMonthlyInvestment.SelectedIndex = 0;
- txtInterestRate.Text = "";
- txtYears.Text = "";
- lblFutureValue.Text = "";
- }
- }
- }