All pastes #392809 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-13 02:37 UTC
rendered paste body
private void btnCalculate_Click(object sender, EventArgs e)
        {
            int years = Convert.ToInt32(txtNumberOfYears.Text);
            int months = years * 12;
            decimal monthlyInvestment = Convert.ToDecimal(txtMonthlyInvestment.Text);
            decimal yearlyInterestRate = Convert.ToDecimal(txtYearlyInterestRate.Text);                      
            decimal monthlyInterestRate = yearlyInterestRate / 12 / 100;

            decimal futureValue = 0m;
            for (int i = 0; i < months; i++)
            {
                futureValue = (futureValue + monthlyInvestment) * (1 + monthlyInvestment);
            }
            txtFutureValue.Text = futureValue.ToString("c");
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }