数组与循环计算

时间:2018-07-30 13:34:52

标签: c# asp.net

我正在对复利进行简单的贷款计算。单击“计算”时,它将在列表框中显示每月的每月付款以及其他信息,例如财产税。但是,这些信息似乎根本没有出现。

private void btnCalculate_Click_1(object sender, EventArgs e)
{
    decimal amount = 0.0m;
    double principal;
    double rate = 0.05;
    int Years;
    int timesPerYear = 12;

    Years = int.Parse(tbLoanTerm.Text); ;
    principal = int.Parse(tbAmount.Text);

    int Months = 0;
    decimal amountMonthly = 0.0m;

    listBox1.Items.Add("Month \t\t\tMonthly Payment\t\t\tProperty Tax");

    while(Months<=360)
    {
        Months = Years * 12;
        double body = 1 + (rate / timesPerYear);
        double exponent = timesPerYear * Years;
        amount = Convert.ToInt32(principal * Math.Pow(body, exponent));

        amountMonthly = amount / Months;

        propertytaxdec = amount * Property_Tax;

        listBox1.Items.Add(Months + "\t\t" + amountMonthly + "\t\t" + propertytaxdec);
        Months++;
    }
}

0 个答案:

没有答案