Need assistance with creating a program to calculate monthly mortgage payment

I need some help on creating this program.

Here is my code so far. I would like to have the formula for the monthly mortgage payment into one C++ statement. Not sure how to approach this.

#include <iosteeam>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
double loan_amount; //Amount of loan
int mortgage_term; // Monthly interest rate
float monthly_payment; // Amount in dollars of the monthly mortgage payment
float monthly_interest_rate, interest_rate;
float divider;

cout << "What is the mortgage amount $";
cin >> loan_amount;
cout << "\n";
cout << "What is the annual interest rate as a percentage ";
cin >> interest_rate;
cout << "\n";
monthly_interest_rate = (interest_rate/100) / 12;
cout << "What is the term of the mortgage in years ";
cin >> mortgage_term;
cout << "\n";


// calculate monthly payment: load amount * i / 1 - 1/(1+ i) to power of number of years * 12)
divider = pow((1 + monthly_interest_rate),(mortgage_term * 12));
monthly_payment =( (loan_amount * monthly_interest_rate) / (1 - (1 /divider)) );

// print output
cout << setprecision(8) << "Mortgage Amount" << setw(11) << loan_amount << endl;
cout << setprecision(5) << "Term of Mortgage" << setw(10) << mortgage_term << " years" << endl;
cout << setprecision(5) << "Annual Interest" << setw(11) << interest_rate << "%" << endl;
cout << setprecision(6) << "Monthly Payment" << setw(11) << monthly_payment << endl;
cout << "\n";
cout << "\n";
cout << "Program Over" << endl;
cout << "\n";
cout << "Press Enter to end -->" << endl;
return 0;
}
Topic archived. No new replies allowed.