The code below was supposed to display interest yearly like:
Year 1 $1000
Year 2 $1100
Year 3 $1210
Problem is it will display the value for the last year for all 3 years... what am i doing wrong?
Code:#include <iostream> #include <cmath> using namespace std; int main() { //Declare variables double percent_return = 0; double investment = 0; int nYears = 0; double value = 0; int count = 0; //Ask user for initial amount cout << "Enter the initial amount of the investment: " << endl; cin >> investment; //Ask user for interest rate cout << "Enter the interest rate: " << endl; cin >> percent_return; //Ask user for number of years cout << "Enter the number of years: " << endl; cin >> nYears; for(count = 1; count <= nYears; count++) { value = investment * pow(1 + percent_return, nYears); cout << value << endl; } return 0; }