(Peter Minuit Problem) Legend has it that, in 1626, Peter Minuit purchased Manhattan Island for $24.00 in barter. Did he make a good investment? To answer this question, modify the compound interest program of Fig. 4.6 to begin with a principal of $24.00 and to calculate the amount of interest on deposit if that money had been kept on deposit until this year (e.g., 384 years through 2010). Place the for loop that performs the compound interest calculation in an outer for loop that varies the interest rate from 5% to 10% to observe the wonders of compound interest.

What will be an ideal response?

[Note: Floating-point math is not exact, so the results may vary between computers.]
```
// Peter Minuit Problem:
// calculating compound interest with several interest rates.
#include
#include
#include // standard C++ math library
using namespace std;

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 ( int rate = 5; rate <= 10; rate++ )
{
// display headers
cout << "\nInterest rate: " << rate << "%\n"
<< "Year" << setw( 30 ) << "Amount on deposit" << endl;

// calculate amount on deposit for each of 384 years
for ( int year = 1; year <= 384; year++ )
{
// calculate new amount for specified year
amount = principal * pow( 1.0 + rate / 100.0, year );

// display the year and the amount
cout << setw( 4 ) << year << setw( 30 ) << amount << endl;
} // end inner for
} // end outer for

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

Computer Science & Information Technology

You might also like to view...

Technology adapted from copiers is used to produce printed output using a(n) ________ printer

Fill in the blank(s) with correct word

Computer Science & Information Technology

________ are actions that Access believes will improve your database performance

Fill in the blank(s) with correct word

Computer Science & Information Technology