### Compund Interest formula problem

Having trouble with the equation for compound interest.

the interest is supposed to be \$43.34 according to the book, I am ending up with around \$35

the actual equation is amount = principal * (1 + rate/t)^t where t = number of times compounded per year.

I still have to go through and clean up all the code I just want the formula working first.

 ``123456789101112131415161718192021222324252627282930313233343536`` ``````#include #include #include using namespace std; int main () { float princ, rate, comp, savings, interest, rates, year; cout<<"What is the principle amount? "; cin>>princ; cout<<"What is the interest rate? "; cin>>rate; cout<<"How many times is it compounded? "; cin>>comp; year = 12 / comp; rates = rate * .1; savings = pow (princ * (1 + rates/comp),year); interest = savings - princ; cout<<"\n\nInterest Rate: "<
 ``12345678910`` ``````double principal = 1000.00 ; double rate_of_interest_per_year = 0.10 ; int number_of_years = 3 ; int number_of_times_compounded_per_year = 4 ; double rate_of_interest = rate_of_interest_per_year / number_of_times_compounded_per_year ; int number_of_times_compounded = number_of_times_compounded_per_year * number_of_years ; double amount = principal * std::pow( ( 1.0 + rate_of_interest ), number_of_times_compounded ) ; double interest = amount - principal ;``````
Thanks for the code, was able to find the mistake in mine.

 ``1234567891011121314`` ``````cout << "What is the Principal: "; cin >> principal; cout << "What is the Interest Rate: "; cin >> rate; cout << "How many times Compounded: "; cin >> t; rates = rate/100; amount = principal * pow(1.0 + rates / t,t); interest = amount - principal; ``````
Topic archived. No new replies allowed.