Array ( [dirname] => . [basename] => frmFutureValue.cs [extension] => cs [filename] => frmFutureValue ) 1. file=./frmFutureValue.cs
2. file=.//frmFutureValue.cs
3. file=frmFutureValue.cs
namespace FutureValue { public partial class frmFutureValue : Form { public frmFutureValue() { InitializeComponent(); } private void btnCalculate_Click(object sender, EventArgs e) { try { decimal monthlyInvestment = Convert.ToDecimal(txtMonthlyInvestment.Text); decimal yearlyInterestRate = Convert.ToDecimal(txtInterestRate.Text); int years = Convert.ToInt32(txtYears.Text); int months = years * 12; decimal monthlyInterestRate = yearlyInterestRate / 12 / 100; decimal futureValue = CalculateFutureValue(monthlyInvestment, months, monthlyInterestRate); txtFutureValue.Text = futureValue.ToString("c"); txtMonthlyInvestment.Focus(); } catch(FormatException) { MessageBox.Show("Invalid numeric format. Please check all entries.", "Entry Error"); } catch(OverflowException) { MessageBox.Show("Overflow error. Please enter smaller values.", "Entry Error"); } catch(Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } private static decimal CalculateFutureValue(decimal monthlyInvestment, int months, decimal monthlyInterestRate) { decimal futureValue = 0m; for (int i = 0; i < months; i++) { futureValue = (futureValue + monthlyInvestment) * (1 + monthlyInterestRate); } return futureValue; } private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }