0
#include <iostream>
#include <cmath>

using namespace std;

int main()

{
double L, APR, Payment, N, brac1, brac2;

		cout <<	"Please enter the loan amount: ";
		cin >>L;
		cout <<	"Please enter the APR: ";
		cin >>APR;
		cout <<	"Please enter the number of payments required: ";
		cin>>N;

		brac1 = 1.0 + APR/1200.0;
		brac2 = 1.0 + APR/1200.0;

		Payment = (L (APR/1200.0) *  pow(brac1,N) ) /  (pow(brac2,N) - 1.0);

			cout<<"The monthly payment for the loan is "<<Payment<<endl;


	return 0;

}

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by firstPerson
-2

No, since you didn't bother to tell us anything. The code does exactly what you told it to do, so it's working.

0

>> (L (APR/1200.0) * pow(brac1,N) ) / (pow(brac2,N) - 1.0);

I think you meant, :

(L * (APR/1200.0) *  pow(brac1,N) )  /  ( pow(brac2,N) - 1.0 );

You know its easier if you do something like this :

// (L  * (APR/1200.0) *  pow(brac1,N) ) /  (pow(brac2,N) - 1.0);
double term1 = L * APR/1200.0;
double term2 = pos(brac1,N); 
double term3 = pow(brac2,N) - 1.0;
double payment = term1 * term2 / term3;

Note that term1,2,3 are bad names. Give them something more meaningful. Dividing the equation into pieces and conquering it is a common strategy. That way you will see the error better.

Edited by firstPerson: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.