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

}

Recommended Answers

All 2 Replies

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

>> (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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.