Building a savings account program?
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: Building a savings account program?

#### Hybrid View

1. Junior Member
Join Date
Mar 2014
Location
Warwick, RI, USA
Posts
3

## Building a savings account program?

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int _tmain() {

// declare variables

int principal = 1000;
double rate = .03;
int years = 1; //counter
double balance = 0.0;

// Begin loop

do{
balance = principal * pow(1 + rate, years);
cout << "year " << years << ":" << endl;
cout << " \$" << balance << endl;
years += 1; //update years counter

} while (years < 6);

system("pause");
return 0;
}

//This is the end of the initial program...

I need to modify the program to use annual interests rates of 3%, 4%, and 5%.

After that I need to modify the program to make it so the user enters the dollar amount of the deposit, the interest rate or rates, and the number of years.

I'm a design student at New England Tech but before we can go full design they want to make sure we know for sure if we want to be a designer or a programmer and so we need to take C++ classes which I suck at so any help would be appreciated.

2. ## Re: Building a savings account program?

First, when posting code please use code tags to make the code readable. Go Advanced, select the code and then click '#'.

Code:
`double rate = .03;`
3% is really 3 / 100 which is .03. So you should be able to change the interest rate to 4%, 5% or any other required interest rate.

For the user to enter data from the keyboard in c++, the stream cin is usually used (as opposed to cout to display). For example
Code:
```double amount;
cin >> amount;```
will obtain the input from the user of type double and store it in the variable amount.

You might also like to look at these sites
http://www.cplusplus.com/doc/tutorial/
http://www.learncpp.com/

3. ## Re: Building a savings account program?

Originally Posted by JSkidds2294
Code:
```#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int _tmain() {

// declare variables

int principal = 1000;
double rate = .03;
int years = 1;       //counter
double balance = 0.0;

// Begin loop

do{
balance = principal * pow(1 + rate, years);
cout << "year " << years << ":" << endl;
cout << "   \$" << balance << endl;
years += 1;     //update years counter

} while (years < 6);

system("pause");
return 0;
}```

//This is the end of the initial program...

I need to modify the program to use annual interests rates of 3%, 4%, and 5%.
Fist you have to use Code tags. Otherwise your code is very hard to read/understand.
Second, what is the problem to "modify the program to use annual interests rates of 3%, 4%, and 5%"?

4. Junior Member
Join Date
Mar 2014
Location
Warwick, RI, USA
Posts
3

## Re: Building a savings account program?

Sorry it was my first time posting on this site also I figured out the problem out before this thread became visible. I was also just asking for tips or examples not the HW done for me. Sorry for the confusion.

5. Junior Member
Join Date
Mar 2014
Location
Warwick, RI, USA
Posts
3

## Re: Building a savings account program?

Also thank you to 2kaud for try to help.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•