// Peter Minuit Problem:
// calculating compound interest with several interest rates.
#include <iostream>
#include <iomanip>
using namespace std;

#include <cmath> // standard C++ math library
using std::pow; // enables program to use function pow

int main()
{
   double amount; // amount on deposit at end of each year
   double principal = 24.0; // initial amount before interest
   double rate; // interest rate

   // set floating-point number format
   cout << fixed << setprecision( 2 );

   // loop through interest rates 5% to 10%
   for ( float rate = 0.05; rate <= 0.10; rate += 0.01 )
   {
      // display headers
      cout << "\nInterest rate: " << rate * 100 << "%\n"
           << "Year" << setw( 30 ) << "Amount on deposit" << endl;

      // calculate amount on deposit for each of ten years
      for ( int year = 1626; year <= 2020; year++ )
      {
         // calculate new amount for specified year
         amount = principal * pow( 1.0 + rate, year - 1626 );

         // display the year and the amount
         if ( year == 1626 || year == 2008 || year == 2010 || 
              year == 2020 || year % 50 == 0 )
         {
            cout << setw( 4 ) << year << setw( 30 ) << amount << endl;
         }
      } // end inner for
   } // end outer for

   return 0; // indicate successful termination
} // end main
