TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
camella Seals
NA
8
701
How to set up a breakpoint to test month and futureValue?
Sep 20 2017 3:16 PM
Hello Everyone,
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 =
""
;
}
}
}
Reply
Answers (
1
)
migrate existing project to asp.net core
Creating Sql Server Reports with wizards