CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    5

    Red face Coding for Interest rate

    Hi Guys!! Can help me how to create coding for calculating interest rate function? I am stuck... Please help..

    Class Account
    Hold variables of interest rate and deposit.
    Make deposit() Withdrawal() function that checks if money in the account is enough to be withdrawn.
    Show output if deposit $5000 for 12 months. 5% interest rate.
    Initial deposit $20000.
    Write main ()

    Codes:

    Code:
    #include <string>
    #include <stdio>
    #include <stdlib>
    #include <conio>
    #include <iostream>
    
    class Account 
    {
    private:
    int Interest; 
    double Deposit; 
    public:
    	Account()
    	{
    		Interest = 0.05;
    		Deposit = 20000;
    	}
    
    	void makeDeposit();
    	void withdrawal();
    };
    
    void Account::makeDeposit()
    {	double amount;
    cout << endl << "Deposit Amount : ";
    cin >> amount;
    	Deposit = Deposit + amount;
    	cout << endl << "Balance : " << Deposit;
    }
    void Account::withdrawal()
    {	double amount;
    cout << endl << "Withdrawal Amount : ";
    cin >> amount;
    	if((Deposit>=0)&&(Deposit >= amount))
    	{Deposit = Deposit - amount;}
    	cout << endl << "Balance : " << Deposit;
    }
    
    void main()
    {
    	Account theAccount;
    	theAccount.makeDeposit();
    	theAccount.withdrawal();
    }
    Last edited by ovidiucucu; June 8th, 2008 at 04:43 AM. Reason: [CODE] tags added

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Coding for Interest rate

    [ Redirected thread ]

  3. #3
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Coding for Interest rate

    Code tags...
    int main not void main...
    Use the constructor's initialiser list
    Specify the actual problem...

    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured