# Building a savings account program?

• March 12th, 2014, 01:29 PM
JSkidds2294
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.
• March 12th, 2014, 02:57 PM
2kaud
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/
• March 12th, 2014, 02:58 PM
VictorN
Re: Building a savings account program?
Quote:

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%"?