I am writing a program that calculates the monthly payment and interest of a loan. I am having trouble getting the program to calculate the Monthly Payment. The correct formula given by my textbook is as follows:
Payment =
Rate * (1 + Rate)^N
 * L
( (1 + Rate)^N  1)
Rate, being the monthly interest rate
N, being the number of payments
L, being the loan amount.

MonthlyIntRate = AnnualIntRate / 12.0;

monthlyPayment = ((MonthlyIntRate * pow(1 + MonthlyIntRate, numPayments)) / (pow(1 + MonthlyIntRate, numPayments)  1.0)) * loanAmount;
