Question
//ITS-250, Week 5 Problem 5 //Task A: Modify this code and replace the while loop with a for loop //Task B: Modify this code to
//ITS-250, Week 5 Problem 5
//Task A: Modify this code and replace the while loop with a for loop
//Task B: Modify this code to allow the user the ability to enter the interest rate
#include
using namespace std;
int main()
{
double investment;
const double INTEREST_RATE = 0.04;
int years;
int count = 1;
cout << "Enter the amount you have to invest. $ ";
cin >> investment;
cout << "Enter the number of years to invest: ";
cin >> years;
while(count <= years)
{
cout << "At the start of year " << count << ", you have $ " << investment << endl;
investment = investment + investment * INTEREST_RATE;
++count;
}
cout << "At the end of the investment period, " << " you have $" << investment << endl;
system("PAUSE");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started