The last function that I need to write for my Uni assignment is to calculate compound interest. I have done this successfully for balances in credit but I am unsure what to so about balances in debit.
This is a code excerptThis works, do I need to make it pow(-1-rate, months) for negative balances?Code:cout <<"\n\tHow many months to you wish to calculate the interest over? "; cin >> months; double principle = 1000; amount = principal * pow( 1.0 + rate, months ); cout <<"\n\tAfter " << months <<" months with a principle of " << principle <<"\n\tYour balance will be:"<< setiosflags( ios::fixed | ios::showpoint )<<"\t" << setprecision( 2 ) << amount <<"\n\n" << endl;
Any help would be appreciated.