(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...

Explain how to finalize your video for DVDs.

What will be an ideal response?

Computer Science & Information Technology

Which search phrase would successfully find the word "book"?

A) b*k B) b?k C) b$k D) b%k

Computer Science & Information Technology

A MAC address contains 32 digits

Indicate whether the statement is true or false

Computer Science & Information Technology

PayPal enables any person or business with an e-mail address to securely, easily, and quickly send and receive payments online.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology