is it possible to have if statements in a function? - need help with compound interest.

Peks

Member
Mar 6, 2003
118
0
0
my formula isnt working for monthly interest compounds.

double compound_interest(double months_par, double interest_rate_par, double balance_par)
{
double compound_interest, total_interest;

total_interest=((interest_rate_par*.01)*(balance_par))*months_par;

compound_interest=balance_par+(pow((1+total_interest/12),12));

return compound_interest;
}



thats my one function.

i dunno what the problem is.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
yes. unless you mean something different than what i think.
 

Peks

Member
Mar 6, 2003
118
0
0
the problem is compound interest. something in the function would be like:


if(months <= 2)
charge compound interest
else
charge reg



now thats english and c++ but the layout applies.
 

Peks

Member
Mar 6, 2003
118
0
0
i actually need to know how to multiply an exponent in c++..no compiler error, just wrong answer.