89.6k views
4 votes
Compute and output compound interest on $1000.00 for 10 years at interest rates of 5%, 6%, 7%, 8%, 9% and 10% This is an exercise in creating nested loops. You must have an inner loop that calculates compound interest via For 1 to 10 amt

1 Answer

6 votes

Here is the complete question.

Compute and output compound interest on $1000.00 for 10 years at interest rates of 5%, 6%, 7%, 8%, 9% and 10%

This is an exercise in creating nested loops. You must have an inner loop that calculates compound interest via

For 1 to 10

amt = rate*amt + amt;

You should have an outer loop that iterates the rate from 0.05 to 1.0.

Interest on $1000.00 over 10 years

rate total

0.05 $1628.89

0.06 $1790.85

0.07 $1967.15

0.08 $2158.92

0.09 $2367.36

0.1 $2593.74

Press any key to continue

Answer:

Step-by-step explanation:

The main objective here is to compute and output compound interest program for the above given data set using the C++.

SO THE PROGRAM GOES THUS:

#include <iostream>

using namespace std;

int main()

{

double amt;

double rate = 0.05;

cout << "\\Compunt interest: " << endl << endl;

cout << "Rate\tTotal" << endl << endl;

for (int i = 0; i < 6; i++)

{

amt = 1000;

for (int j = 0; j < 10; j++)

{

amt = (rate * amt) + amt;

}

cout << rate << "\t$" << amt << endl;

rate = rate + 0.01;

}

system("pause");

}

AND THE SAMPLE OUTPUT IS:

Compound Interest:

Rate Total

0.05 $1628.89

0.06 $1790.85

0.07 $1967.15

0.08 $2158.92

0.09 $2367.36

0.1 $2593.74

Press any key to continue...

User Pavpanchekha
by
4.7k points