1. ## Loan calculation formula

Hello all,

I wrote this program to work out monthly payment for personal loan. Say, you borrow 15000 (principal) at 7.50% APR for 4 years?
So my formula is (maybe wrong):-
1. months = 4 * 12;
2. interest = principal * 7.50 / months;
3. monthlypayment = (principal + Interest) / months;

My monthly payment comes out as 361.38, is this correct?
What is correct formula to do this?

Here is my program, just in case you want to see it. Thanks.

Code:
```// Calculating loan payment/interest
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
char again;

do
{
system("CLS");

double amount,	//amount per month
principal,	//loan amount
rate,		//interest rate
interest,	//total interest
months,		//months
years,		//years term
totalpayment;

// set the floating-point number format
cout << setiosflags( ios::fixed | ios::showpoint )
<< setprecision( 2 );

cout << "Enter amount of loan: ";
cin >> principal;
cout << "Enter rate ( APR % ): ";
cin >> rate;
cout << "Enter number of years: ";
cin >> years;

//some calculation
months = years * 12;
interest = principal * rate / months;
amount = (principal + interest) / months;
totalpayment = principal + interest;

//display
cout << endl << "LOAN CALCULATION:";
cout << endl << "=================" << endl;
cout << "Total Loan      : " << setw( 8 ) << principal << endl;
cout << "Rate APR %      : " << setw( 8 ) << rate << endl;
cout << "Total years     : " << setw( 8 ) << years << endl;
cout << "Total interest  : " << setw( 8 ) << interest << endl;
cout << "Monthly payment : " << setw( 8 ) << amount << endl;
cout << "Total Payment   : " << setw( 8 ) << totalpayment << endl << endl;
cout << "Again y/n? ";
cin >> again;
} while (again == 'y' );
return 0;
}```

2. ## Hello!

What is correct formula to do this?
This might help you! When I am having problems with some of my formulas i goto ask Dr. Math . Goto google, then type in that name its a fantastic website for people like myself who are not so good with math.
I hope this helps!
Later.