Ok so the second part of my homework for today is this.
// Write a compound-interest calculator. It should read in the principal
// amount (initial investment), the annual nominal interest rate, the
// number of times the interest is compounded per year and the number of
// years invested. It should then output the final amount to the nearest
// Your input and output should look like this:
// Enter the principal amount in dollars: 1000
// Enter the annual nominal interest rate: 3.5
// Enter the number of times the interest is compounded per year: 12
// Enter the number of years invested: 3
// The final amount is $1110.54.
Given those facts I wrote my program and used those numbers to test my math, needless to say I didn't get the same result. After several hours of toiling I decided to ask for help. No matter how I work the equation for compound interest I cant replicate the results. So without further ado here is my code to this point
int principal_amount, compound_num, years_invested; double annual_interest, final_amount,alpha_interest,alpha, bravo, charlie; cout << "Please enter the principal amount in dollars: "; cin >> principal_amount; cout << "Please enter the annual nominal interest rate: "; cin >> alpha_interest; cout << "Please enter the number of time the interest is compounded per year: "; cin >> compound_num; cout << "Please enter the number of years invested: "; cin >> years_invested; cout << showpoint; cout << setprecision(5); annual_interest = alpha_interest / 100; cout << "\n" <<annual_interest<< "\n"; alpha = compound_num / annual_interest; bravo = alpha + 1; charlie = compound_num * years_invested; final_amount = principal_amount * bravo * charlie; cout << "\n The Final Amount Is: $"<<final_amount<< "\n"; // A zero return value indicates that the program finished without error. return 0; }
Please look through this code and let me know what I can do to resolve this.