#include #include //for the "i/o manipulators" setw and setprecision #include using namespace std; //Interest is 6% annually. int main() { int nyears {0}; cout << "How many years?\n"; cin >> nyears; if (!cin) { cerr << "Not an acceptable number.\n"; return EXIT_FAILURE; } double principal {1000.00}; //start with this many dollars cout << "Starting with what principal?\n"; cin >> principal; if (!cin) { cerr << "Not an acceptable principal\n"; return EXIT_FAILURE; } double rate {0.0}; cout << "What is the annual interest rate in percent (e.g., 6)? "; cin >> rate; if (!cin) { cerr << "not an acceptable rate\n"; return EXIT_FAILURE; } cout << "year principal\n" //column headings << "---- ---------\n"; for (int year {1}; year <= nyears; ++year) { principal *= 1 + 0.1 * rate; //means principal = principal * 1.06 cout << " " << setw(2) << year << " $" << fixed << setprecision(2) << principal << "\n"; } return EXIT_SUCCESS; }