Tuesday 21 July 2020

5.14 (Modified Compound-Interest Program) Modify the compound-interest application of Fig. 5.6 to repeat its steps for interest rates of 5%, 6%, 7%, 8%, 9% and 10%. Use a for loop to vary the interest rate.

Q  5.14 (Modified Compound-Interest Program) Modify the compound-interest application of Fig. 5.6 to repeat its steps for
interest rates of 5%, 6%, 7%, 8%, 9% and 10%. Use a for loop to vary the interest rate.

#include < iostream>
using std: : cout;
using std: : endl;
using std: : fixed;
#include < iomanip>
using std: : setw// enables program to set a field width
using std: : setprecision;
#include < cmath> // standard C++ math library
using std: : pow// enables program to use function pow
int main()
{
double amount// amount on deposit at end of each year
double principal;
// display headers
cout << setw<< "Year" << setw<< "Dep. (%X) " <<endl;
// set floating‐point number format
cout << fixed << setprecision;
forint rate 5rate <= 10rate++) {

principal 1000. 0;
// calculate amount on deposit for each of ten years
for int year 1year <= 10year++)
{
principal principal powrate/100. 0, year ;
cout << setw<< year << setw<< principal << endl;
}
cout << endl;
}/
/ end for
system("pause";
return 0// indicate successful termination
// end main

No comments:

Post a Comment