Thread: Problems with Bank account class

  1. #1
    Registered User
    Join Date
    Aug 2006

    Problems with Bank account class

    Hi everyone,
    basically i have some problem in doing my C++ bank account class.I need to create a base class bank with withdrawal,deposit and calculation of balance where there must be a name, account number and type.
    i need also to create derived class Saving of a saving account, which allows overdraft up to $8000 and gives interest of 2% per annum and another derived class Current of a current account, which does not allow overdraft and does not give any interest.
    Two objects of the derived classes with initial deposits of $2000 and $5000 each. showing interest calculation for one month and and giving warning when the account balance is zero or less.
    Now i am stuck with continuing my work.
    This is what i have done so far:

    #include <iostream>
    #include <iomanip>
    #include <string>
    using namespace std;
    class Bank  {
    	char nm[20];
    	int accno;
    	float damt,wamt,t,bamt,iamt;   
    //amt=amount where d=deposit , w=withdraw, t=total ,b=balance, i=initial(starting amount)
    	void intro();
    	void deposit();
    	void withdraw();
    	void display();
    	void bal();
    	void ivalue();
    void Bank ::intro()
    	cout<< "\nAccount Name: ";
    	cout<< "\nAccount No: ";
    	cout<< "\nType: Saving\n ";
    void Bank::ivalue()
    void Bank ::bal()
    	cout<<"Balance: $"<<iamt<<endl;
    void Bank ::withdraw()
    	cout<<" \nEnter positive amount to deposit and negative to withdraw: $";
    void Bank ::display()
    		cout<<nm<<setw(10)<<"Not enough balance to be withdrawn\n";
    		cout<<"Maximum money can be withdrawn Rs"<<t<<"\n";
    void main()
    	Bank jacky;
    	Saving john;
    Any help will be appreciated thanks.

    edit:sorry just added code tags
    Last edited by xianglin139; 08-09-2006 at 10:10 AM.

  2. #2
    Ethernal Noob
    Join Date
    Nov 2001
    code tags please.

  3. #3
    C / C++
    Join Date
    Jan 2006
    The Netherlands
    Start with something like this:

    class Saving: public Bank
    // code
    First result on searching Derived class in Firefox address bar:
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    I have problems with my bank account too. I think it's missing a few digits.

    Hope is the first step on the road to disappointment.

  5. #5
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    >>float damt,wamt,t,bamt,iamt;

    Don't know about your bank, but mine doesn't have that many "amts."

    You should have stated what you need help with - We shouldn't have to read
    your code to see where you got stuck (sometimes we like things spelled out).

    This might just be me, but I don't think that member functions should involve
    cout - I like to pass any data that a member might need to it from main/some
    other function - class members aren't like other (global) functions - they should
    only have what is needed to manipulate the data in the class. Also, since I
    assume that this is a beginners C++ assignment, it might make sense to have
    some members that return information about the status of the bank account -
    your display member does it, but there's the whole cout thing I mentioned -
    also main can't access that value - it would be better to return the balance
    instead IMO. Also, why does your constructor and your ivalue function do the
    same thing?

    Lastly, see my sig on using void main - it's bold and I won't be your friend if you
    use it
    No No's:
    fflush (stdin); gets (); void main ();

    Example of fgets (); The FAQ, C/C++ Reference

    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition

    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need the code of few programs in c++.plzzzzz help...plzzz
    By NAVINKR20 in forum C++ Programming
    Replies: 1
    Last Post: 05-08-2009, 09:13 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Bank Account
    By vasanth in forum A Brief History of
    Replies: 7
    Last Post: 09-14-2003, 02:27 AM
  4. Simple Bank Account Uni Project Help!!!
    By griff in forum C Programming
    Replies: 3
    Last Post: 05-09-2003, 05:49 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM