Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having trouble with adding a feature to code...... Manipulate the following

ID: 3625326 • Letter: I

Question

I am having trouble with adding a feature to code......

Manipulate the following code, to either have a menu so the person can select an interest rate from six different rates, or you can have them enter a rate and use that.

Modify the program to display the year and amount for 30 years. Be sure to test your program and use appropriate comments.


#include<iostream>

Using std::cout;
Using std::fixed;
Using std::endl;

#include<iomanip>
Using std::setw;
Using std:: setprecision;

#include<cmath>
using std::pow;

int main()
{

Double amount; //amount on deposit at the end of each year//
Double princ=1000.0; // initial amount before interest//
Double rate=.05; //interest rate//
cout<<fixed<<setprecision(2);// set floating point number format
cout<< “Year 5% 6% 7% 8% 9% 10%”<<endl; // display headers//
cout<”-------------------------------------------------“<<endl;
for(int year=1; year,=10; year++) // count from 1 to 10//
{
Cout<<setw(4)<<year; // output year//
for(int r=5; r<10; r++)// calculate interest//
{
Rate=r/100.0; // cal new amount for specified year//
Amount=principal*pow(1.0+rate, year);//print year and amount//
Cout<<setw(10)<<amount; //end of inner for//
}
Cout<<endl;// end of outer for
}
Return 0;
}




Explanation / Answer

please rate - thanks

using std::fixed;
using std::endl;

#include<iomanip>
using std::setw;
using std:: setprecision;

#include<cmath>
using std::pow;

int main()
{

double amount; //amount on deposit at the end of each year//
double princ=1000.0; // initial amount before interest//
double rate;
cout<<"Enter the interest rate (ex: 5.5% enter 5.5): ";
cin>>rate;
rate=rate/100;
cout<<fixed<<setprecision(2);// set floating point number format
cout<<"Year amount"<<endl; // display headers//
cout<<"------------------------------------------------------"<<endl;
for(int year=1; year<=30; year++) // count from 1 to 10//
{

amount=princ*pow(1.0+rate, year);//print year and amount//
cout<<year<<" "<<amount<<endl;
}
cout<<endl;// end of outer for

system("pause");
return 0;
}