Here is my code for the same exact program. I have everything working except for displaying the calculated monthly interest. I could use some help.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double mortgage, interest, payment, years, monthlyInterest, monthlyBalance, numPayments;
int counter;
cout << "Please enter a mortgage amount: ";
cin >> mortgage;
cout << "Please enter an annual interest rate: ";
cin >> interest;
cout << "Please enter a payment amount: ";
cin >> payment;
cout << "Please enter number of years for the loan: ";
cin >> years;
cout << "Month" << '\t' << "Balance" << '\t' << '\t' << "Payment" << '\t'<< '\t' << "Interest" << endl;
numPayments = (years * 12);
interest = interest / 100;
monthlyBalance = 1;
monthlyInterest = 1;
for (counter = 1; counter <= numPayments; counter++)
{
cout << counter << '\t' << setiosflags(ios::fixed) << setprecision(2) << mortgage << '\t' <<
payment << '\t' << '\t' << setiosflags(ios::fixed) << setprecision(2) << monthlyInterest << endl;
mortgage = mortgage - payment;
monthlyInterest = ((mortgage) * (interest / 12));
mortgage = mortgage + monthlyInterest;
}
}