(Compound Interest) Modify the compound interest program of Section 4.4 to repeat its steps for the interest rates 5%, 6%, 7%, 8%, 9% and 10%. Use a for statement to vary the interest rate.
What will be an ideal response?
```
// Calculating compound interest with several interest rates.
#include
#include
#include
using namespace std;
int main()
{
double amount; // amount on deposit
double principal = 1000.0; // starting principal
// set floating-point number format
cout << fixed << setprecision( 2 );
// loop through interest rates 5% to 10%
for ( int rate = 5; rate <= 10; rate++ )
{
// display table headers
cout << "Interest Rate: " << rate << "%"
<< "\nYear\tAmount on deposit\n";
// calculate amount on deposit for each of ten years
for ( int year = 1; year <= 10; year++ )
{
// calculate new amount for specified year
amount = principal * pow( 1 + ( rate / 100.0 ), year );
// output one table row
cout << year << '\t' << amount << '\n';
} // end for
cout << '\n';
} // end for
cout << endl;
} // end main
```
You might also like to view...
When creating a query, you can select contiguous tables by selecting the first table, and then by pressing the Ctrl key while clicking the last table in the Show Table dialog box
Indicate whether the statement is true or false
The chain of custody accounts for the handling of evidence and documents that handling
Indicate whether the statement is true or false.
To draw a context diagram, you start by placing a single process symbol on the top right corner of the page.
Answer the following statement true (T) or false (F)
Both near-end crosstalk (NEXT) and far-end crosstalk (FEXT) are measured in __________.
A. Ohms B. Amps C. Hertz D. decibels