Principal: 1000 Rate: 12% Year Amount on deposit 1 1120.00 2 1254.40 3 1404.93 4 1573.52 5 1762.34 1973.82 2210.68 8 2475.96 2773.08 10 3105.85
C++
This Code displays the following output
Initial principal: 1000
Interest Rate: 5%
Year Amount on deposit
1 1050
2 1102.5
3 1157.63
4 1215.51
5 1276.28
6 1340.1
7 1407.1
8 1477.46
9 1551.33
10 1628.89
Initial principal: 1000
Interest Rate: 6%
Year Amount on deposit
1 1060
2 1123.6
3 1191.02
4 1262.48
5 1338.23
6 1418.52
7 1503.63
8 1593.85
9 1689.48
10 1790.85
Initial principal: 1000
Interest Rate: 7%
Year Amount on deposit
1 1070
2 1144.9
3 1225.04
4 1310.8
5 1402.55
6 1500.73
7 1605.78
8 1718.19
9 1838.46
10 1967.15
Initial principal: 1000
Interest Rate: 8%
Year Amount on deposit
1 1080
2 1166.4
3 1259.71
4 1360.49
5 1469.33
6 1586.87
7 1713.82
8 1850.93
9 1999
10 2158.92
Initial principal: 1000
Interest Rate: 9%
Year Amount on deposit
1 1090
2 1188.1
3 1295.03
4 1411.58
5 1538.62
6 1677.1
7 1828.04
8 1992.56
9 2171.89
10 2367.36
Initial principal: 1000
Interest Rate: 10%
Year Amount on deposit
1 1100
2 1210
3 1331
4 1464.1
5 1610.51
6 1771.56
7 1948.72
8 2143.59
9 2357.95
10 2593.74
The amount of deposit is not properly formatted. Format the amount of deposit to be just like it is in this picture using the given code.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double principal{ 1000 };
double rate{ 0.05 };
for (rate; rate <= 0.10; rate += 0.01) {
cout << "" << endl;
cout << "Initial principal: " << principal << endl;
cout << "Interest Rate: " << rate * 100 << "%" << endl;
cout << setw(4) << "Year" << setw(20) << "Amount on deposit" << endl;
for (unsigned int year{ 1 }; year <= 10; year++) {
double amount = principal * pow(1.0 + rate, year);
cout << setw(4) << year << setw(20) << amount << endl;
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images