I set up my breakpoint at this statement,
futureValue= (futureValue + monthlyInvestment) * (1+ monthlyInterestRate);
but if I want to create conditions to determine each month (this starts a 0) and the future value of each month or index, how could I do this in the conditional expression dialog box using a breakpoint? I did research for a similar question on this website and only found these pages: (Set breakpoints in an ASP.NET Web Site Project, Break points aspx pages, How to set conditional breakpoints in Visual Studio?). Also, after I set up the breakpoint, wouldn't it display those specific month and futureValue values in web application program if I run. Here is my C# code only since I think it's the only file that I think needs to be here.
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 = "";
}
}
}