Well I'm just a beginner and I needed help understanding why my formula for the monthly payment of a loan doesn't work. Here's my work:
/ Calculating Loan Payments
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double R, P, r, m, t, TotalPayment, TotalInterest;
cout << "Enter yearly interest rate: " << endl;
cin >> r;
cout << "Enter the number of years you would like to pay off the loan: " << endl;
cin >> t;
cout << "Enter loan amount: " << endl;
cin >> P;
m = 12;
r = r / 100;
R = P / (1 - pow((1 + r / m), (-m*t)) / r / m);
cout << "Your Monthly Payment is " << R << endl;
TotalPayment = R * 12 * t;
cout << "Your total payment is: " << TotalPayment << endl;
TotalInterest = TotalPayment + P;
cout << "Your total interest rate is: " << TotalInterest << endl;
return 0;
}
I'm a beginner so it might be just something easy to see for someone more experienced. Thanks a lot.