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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!