Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago