0

Hello C# experts!

can't figure it out. obviously i'm missing something.

here is part of my code:

```
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 5;
dataGridView1.Columns[0].HeaderText = "Payment #";
dataGridView1.Columns[1].HeaderText = "Monthly Payment";
dataGridView1.Columns[2].HeaderText = "Amount to Interest";
dataGridView1.Columns[3].HeaderText = "Amount to Principal";
dataGridView1.Columns[4].HeaderText = "Remaining Balance";
double loan, cost, downPmt, months, APR = 0, newAPR, usedAPR, monthlyPmt = 0, interest = 0, principal = 0;
cost = double.Parse(textBox1.Text);
downPmt = double.Parse(textBox2.Text);
months = double.Parse(textBox3.Text);
loan = cost - downPmt;
newAPR = .069;
usedAPR = .085;
dataGridView1.Rows.Clear();
for (int payments = 1; payments <= months; payments++)
{
if (radioButton1.Checked)
textBox4.Text = newAPR.ToString("0.0%");
else
textBox4.Text = usedAPR.ToString("0.0%");
if (radioButton1.Checked)
APR = newAPR;
else
APR = usedAPR;
monthlyPmt = Financial.Pmt(APR, months, -loan);
principal = Financial.PPmt(APR, months, months, -loan);
interest = Financial.IPmt(APR, months, months, -loan);
dataGridView1.Rows.Add();
dataGridView1.Rows[payments - 1].Cells[0].Value = payments;
dataGridView1.Rows[payments - 1].Cells[1].Value = monthlyPmt.ToString("c");
dataGridView1.Rows[payments - 1].Cells[2].Value = interest.ToString("c");
dataGridView1.Rows[payments - 1].Cells[3].Value = principal.ToString("c");
loan -= principal;
dataGridView1.Rows[payments - 1].Cells[4].Value = loan.ToString("c");
interest += principal;
}
}
```

and it's coming out like this, which is incorrect.

http://oi50.tinypic.com/faszo6.jpg

it's supposed to be like this:

http://oi45.tinypic.com/1zoje6g.jpg

i must be doing something wrong in the interest calculations?

i'd appreciate the help, thanks.