0
public mainForm()
{
InitializeComponent();
}
string[,] summary = new string[10, 4];
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void calculateButton_Click(object sender, EventArgs e)
{
decimal monthlyInvestment =
Convert.ToDecimal (monthlyInvestmentTextBox.Text);
decimal yearlyInterestRate =
Convert.ToDecimal (interestRateTextBox.Text);
int years =
Convert.ToInt32(yearsTextBox.Text);
int months = years * 12;
decimal monthlyInterestRate = yearlyInterestRate/12/100;
decimal futureValue = 0;
for (int i = 0; i < months; i++)
{
futureValue = (futureValue + monthlyInvestment)
* (1 + monthlyInterestRate);
}
futureValueTextBox.Text = futureValue.ToString("c");
monthlyInvestmentTextBox.Focus();
}
该程序根据费率和年数计算投资的未来值。一旦用户点击计算,我希望程序以10x4的数组形式存储多达10次计算。 4是投资,利率,年份和未来价值。点击退出按钮后,我想要一个消息框显示10个以前的计算。我会如何去做这件事?谢谢。使用矩形阵列存储值
不要使用矩形数组,为投资,费率,年数和未来价值的属性创建一个'FutureInvestments'类。然后,如果您需要存储其中的10个,请使用“List” –