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

Thread: Building a savings account program?

  1. #1
    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. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,277

    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.

    For more info about cin see http://www.cplusplus.com/reference/iostream/cin/

    You might also like to look at these sites
    http://www.cplusplus.com/doc/tutorial/
    http://www.learncpp.com/
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Building a savings account program?

    Quote Originally Posted by JSkidds2294 View Post
    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%"?
    Third, about homework.
    Victor Nijegorodov

  4. #4
    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. #5
    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center