Mortgage Chart

I'm trying to print out a mortgage chart that loops through and keeps on outputting the payments, total principal and interest paid and such.
I'm going brain dead and I can't think, or remember, how to get the values from the first time the loop runs to carry over for each time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 for (int i = 0; i < (loanTerm * 12); i++)
   {
      interest   = loanAmt * intRate;
      principal  = monthlyPay - interest;
      totalBal   = loanAmt - principal;
      totalPrin += principal;
      totalInt  += interest;

      cout.setf(ios::fixed);
      cout.setf(ios::showpoint);
      cout.precision(2);
      
      cout << setw(3) << i + 1 << setw(13) << principal << setw(11) << interest
           << setw(11) << totalPrin << setw(10) << totalInt << setw(11)
           << totalBal << endl;      
   }



EDIT: I just moved stuff around and it started working. No worries!
Last edited on
Topic archived. No new replies allowed.