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)) );