0

Hello all! I'm new to the forum and need some help. I finished most of the code already but I am stuck now. I'm trying to create a program that shows the interst and payment on a loan. I want to add som code that will sum the amount of interest paid in total and allow you to pay extra on the principla of at any payment. Thanks in advance for any help.

```
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
float prin, air = .1, np = 36, date, pay, mpr, mi, bal;
int n = 0, year = 13, month = 0;
cout<<"Enter principal amount: \n";
cout<<"$";
cin>>bal;
cout<<"Enter annual interest rate in decimal form: "<<endl;
cin>>air;
cout<<"Enter number of payments in months: \n";
cin>>np;
mpr = air / 12;
pay = mpr * (bal / (1 - (1 / pow((1 + mpr), np))));// WHY YOU NO WORK!!!!!!!
cout<<"Payment is: "<<pay<<endl;
cout<<"Payment: Due Date Number Payment Principal Interest Balance "<<endl;
while (n < np)
{
n++;
month++;
if (month>12)
{
month = 1;
year++;
}
mi = bal * mpr;
prin = pay - mi;
bal = bal - prin;
cout.setf(ios::fixed);
cout<<setw(10)<<setprecision(2)<<month<<"/5/"<<year<<setw(7)<<n<<setw(11)<<pay<<" "<<prin<<" "<<mi<<" "<<bal<<endl;
}
return 0;
}
```