'pow' : no overloaded function takes 1 arguments

I keep getting this error in my code. I believe it is because to use pow(x,y) both x and y have to be double, but how do i put that into my formula under calculations?

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;

int main()
{
// Declaration section: Declaring all variables.

string loan_type, Auto;
double loan_amt, annual_rate, monthly_payment, monthly_rate, total_amt, interest_paid, number_of_payments, number_of_years;
ofstream outfile;
// Input Section: User gives the program the information needed to create report

cout << "Enter your type of loan <Auto, Home>: ";
cin>> loan_type;

// If loan is an auto loan

if (loan_type == "Auto")
{
cout << "Amount to borrow: ";
cin>> loan_amt;
cout << "How many payments <36, 48, 60>: ";
cin>> number_of_payments;
}

//Else is if it is a home loan

else
{
cout << "Amount to borrow: ";
cin>> loan_amt;
cout << "How many years <15, 20, 30>: ";
cin>> number_of_years;
}
if (number_of_payments == 36)
{
annual_rate=0.06940;
}
else if (number_of_payments == 48)
{
annual_rate=0.07010;
}
else if (number_of_payments == 60)
{
annual_rate=0.08050;
}

// If the nummber of years is 15, 20, or 30 then the number of payments is 180, 240, or 360 and their interest rates

if (number_of_years == 15)
{
number_of_payments=15*12;
annual_rate=0.03750;
}
else if (number_of_years == 20)
{
number_of_payments=20*12;
annual_rate=0.04125;
}
else if (number_of_years == 30)
{
number_of_payments=30*12;
annual_rate=0.05250;
}

// Finding monthly interest rate for different annual rates
if (annual_rate == 0.06940)
{
monthly_rate=annual_rate/12;
}
else if (annual_rate == 0.07010)
{
monthly_rate=annual_rate/12;
}
else if (annual_rate == 0.08050)
{
monthly_rate=annual_rate/12;
}
else if (annual_rate == 0.03750)
{
monthly_rate=annual_rate/12;
}
else if (annual_rate == 0.04125)
{
monthly_rate=annual_rate/12;
}
else if (annual_rate == 0.05250)
{
monthly_rate=annual_rate/12;
}

// Calculations

cout << setprecision(2) << fixed;
monthly_payment=monthly_rate*pow((1+monthly_rate),number_of_payments)/pow(((1+monthly_rate),number_of_payments)-1)*loan_amt;
total_amt=monthly_payment*number_of_payments;
interest_paid=total_amt-loan_amt;

// Output

cout << "--- Loan Report ---" << endl;
outfile << "--- Loan Report ---" << endl;
cout << "Loan Type: " << loan_type << endl;
outfile << "Loan Type: " << loan_type << endl;
cout << "Loan Amount: " << loan_amt << endl;
outfile << "Loan Amount: " << loan_amt << endl;
cout << "Annual Interest Rate: " << annual_rate << endl;
cout << "Annual Interest Rate: " << annual_rate << endl;
cout << "Number of Payments: " << number_of_payments << endl;
outfile << "Number of Payments: " << number_of_payments << endl;
cout << "Monthly Payment: " << monthly_payment << endl;
outfile << "Monthly Payment: " << monthly_payment << endl;
cout << "Total Payment: " << total_amt << endl;
outfile << "Total Payment: " << total_amt << endl;
cout << "Interest Paid: " << interest_paid << endl;
outfile << "Interest Paid: " << interest_paid << endl;

system("pause");
return 0;
}
9000
9001
//look carefully:
monthly_payment=monthly_rate*pow((1+monthly_rate),number_of_payments)/pow(((1+monthly_rate),number_of_payments)-1)*loan_amt;
I'm sorry I still cannot see it.
pow(((1+monthly_rate),number_of_payments)-1)

1
2
pow( ((1+monthly_rate),
      number_of_payments)-1)
The comma is inside the inner parens, not the pow function parens.

Perhaps you meant this instead:

(pow((1+monthly_rate),number_of_payments)-1)
Last edited on
Or it could be:
pow( (1 + monthly_rate) , (number_of_payments - 1 ) )
Topic archived. No new replies allowed.