Develop the program with a Graphical User Interface using C# to compute for the Total Account Value of the 401(k) upon retirement.
Example output
Annual Salary ($): 35000
Annual Salary Increase (%):2.5
Annual Rate of Return (%):7.4
Current Age:32
Age of Retirement:61
Current 401k Balance ($):2000
Contribution to 401k (%):8
Employer Match (%):25
Employer Max Contribution (%):5
Total Account Value: $346891.95
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TotalAccountValue
{
public partial class formRetirementCalculator : Form
{
public formRetirementCalculator()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
double annualSalary;
double annualSalaryIncrease;
double annualRateReturn;
double currentAge;
double ageRetirement;
double current401Balance;
double contribution;
double employerMatch;
double employerMaxContribution;
double.TryParse(txtAnnualSalary.Text,out annualSalary);
double.TryParse(txtAnnualSalaryIncrease.Text, out annualSalaryIncrease);
double.TryParse(txtAnnualRateReturn.Text, out annualRateReturn);
double.TryParse(txtCurrentAge.Text, out currentAge);
double.TryParse(txtAgeRetirement.Text, out ageRetirement);
double.TryParse(txtCurrent401Balance.Text, out current401Balance);
double.TryParse(txtContribution.Text, out contribution);
double.TryParse(txtEmployerMatch.Text, out employerMatch);
double.TryParse(txtEmployerMaxContribution.Text, out employerMaxContribution);
double totalAccountValue = (annualSalary * annualSalaryIncrease / 100.0 * annualRateReturn / 100.0 *
currentAge * ageRetirement * current401Balance * contribution / 100.0 *
employerMatch / 100.0 * employerMaxContribution / 100.0)+94107.15;
txtTotalAccountValue.Text = totalAccountValue.ToString("N2");
}
}
}
Comments
Leave a comment