So I have a program i am writing. relatvely simple, but i am not sure what to do. the first I am trying to make a program that displays loan amount, monthly payments, and number of payments based on the input (annual interest rate), (number of payments), and (amount of loan). I have assigned l as loan amount, n as number of payments and rate as the annual interest rate/12. My formula for calculating is as follows : payment= (lrate(1+rate)n)/((1+rate)n-1)(n being to the nth(number of payments)power

I am getting an error on the line highlighted in red, but I am not sure that is going to make it work correctly

here is my code:

``````// Calculates loan info
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
double annualrate;
int numberofpayments;
double l;
double rate;
double rateplus1;
double divisor;
double payment;
double paymentbd;
double dividend;

cout << "What is your annual interest rate?\n";
cin >> annualrate;
rate = annualrate/1200;
cout <<"Enter number of payments.\n";
cin >> numberofpayments;
rateplus1= rate+1;
cout << "Enter your loan amount\n";
cin >> l;
divisor= pow (rate+1),(numberofpayments);

dividend=divisor-1;
paymentbd= l*rate* divisor;
payment=paymentbd/ (divisor-1);
cout <<"Your loan amount is "<<l<<".\n";
cout <<"Your monthly payments are "<<payment<<".\n";
cout <<"Your number of payments are "<<numberofpayments<<".\n";

return 0;
}
``````

I think you meant this, rather than what you had.

``divisor=pow ((rate+1),(numberofpayments));``

If this doesn't fix it, let me know. I only looked at that line, and not at the rest of your code.

Be a part of the DaniWeb community

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