// // Filename: pgm2_5b.cpp // // Description: Computing simple interest over 'n' periods // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // #include #include #include main() { double amount; double principal; double rate; int year; cout << "Enter the initial principal: "; cin >> principal; cout << "You entered: " << principal << " dollars.\n" << endl; cout << "Enter the yearly interest rate ( 0.0-1.00 ): "; cin >> rate; cout << "Your yearly interest rate is: " << rate << endl << endl; cout << "Enter the number of years: "; cin >> year; cout << "The number of years is: " << year << endl << endl; cout << "Year" << setw(21) << "Amount on Deposit" << endl; cout << "****" << setw(21) << "*****************" << endl; for( int i=1; i<=year; i++) { amount = principal * pow( 1.0 + rate, i ); cout << setw(4) << year << setiosflags( ios::fixed ) << setw(21) << setprecision(2) << amount << endl; } return 0; }