You are using a version without Ads of this website. Please, consider donating:

### Question with exponents

This is only my 5th program.

I am writing a program that will calculate the monthly payment on a loan.

They tell you to use the formula :

Payment = Rate * (1+Rate)^N / ((1+Rate)^N - 1) * L

N = number of payments

L = loan amount

So here is the code i wrote.

`MonthlyPayment = (MonthlyIntRate * pow((1.0 + MonthlyIntRate), NumberOfPayments)) / (pow((1.0 + MonthlyIntRate),NumberOfPayments) - 1.0);`

All the variables are double. And im using cmath.

The program will compile just fine, but it will only output with whatever I enter for the MonthlyIntRate.

Help!
I don't see you have included the loan amount in the code.
I missed that when I was copying, but its there and im still having the same issue.
How do you miss something with copy and paste? Paste the exact code, don't type it by hand.
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071`` ``````#include #include #include using namespace std; int main(int argc, char *argv[]) { double LoanAmt, MonthlyIntRate, NumberOfPayments, MonthlyPayment, AmtPaidBack, IntPaid; cout << "How much is your loan amount? "; cin >> LoanAmt; cout << "\n \n"; cout << "What is the monthly interest rate? "; cin >> MonthlyIntRate; cout << "\n \n"; cout << "Number of payments? "; cin >> NumberOfPayments; cout << "\n \n"; // Calculations // I couldn't get the math to come out right. MonthlyPayment = (MonthlyIntRate * pow((1.0 + MonthlyIntRate), NumberOfPayments)) / (pow((1.0 + MonthlyIntRate),NumberOfPayments) - 1.0) * LoanAmt; cout << "\n \n"; // Displays the calculations cout << "Loan Amount: \$" << LoanAmt << "\n"; cout << "Monthly Interest Rate: " << MonthlyIntRate << "\n"; cout << "Number of Payments: " << NumberOfPayments << "\n"; cout << "Monthly Payment: \$" << MonthlyPayment << "\n"; cout << "Amount Paid Back: \$" << AmtPaidBack << "\n"; cout << "Interest Paid: \$" << IntPaid << "\n"; system("PAUSE"); return 0; }``````
Topic archived. No new replies allowed.