Banking System

This is a discussion on Banking System within the C++ Programming forums, part of the General Programming Boards category; Define a class to represent a bank account. Indicate the following member. 1. Name of depositor. 2. Account numer. 3. ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Location
    Jaipur
    Posts
    1

    Red face Banking System

    Define a class to represent a bank account. Indicate the following member.
    1. Name of depositor.
    2. Account numer.
    3. Type of account.
    4. Blance amount in the account.

    Member Function.
    1. To assign initial values.
    2. To deposit an amount.
    3. To with draw and amount after checking the balance.
    4. To display name and balance.

  2. #2
    Registered User
    Join Date
    Nov 2008
    Posts
    42
    You should try out yourself, here is now a place for homework. Read the sticked post,plz

  3. #3
    Registered User
    Join Date
    Mar 2009
    Location
    the middle of nowhere
    Posts
    11
    What's the question?

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by CrustyClown View Post
    What's the question?
    I think the question is implicit. "How much money will it take for me to not have to do my own homework?"
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    The problem is very straightforward. We'll help if you make an effort.

  6. #6
    Registered User BuzzBuzz's Avatar
    Join Date
    Feb 2009
    Posts
    89
    Quote Originally Posted by CrustyClown View Post
    What's the question?
    It doesn't appear to be question, I think it is the G20 solution to the banking crisis. It's not like it could be any more ineffective than the current proposals......

    Banking System
    Define a class to represent a bank account. Indicate the following member.
    1. Name of depositor.
    2. Account numer.
    3. Type of account.
    4. Blance amount in the account.

    Member Function.
    1. To assign initial values.
    2. To deposit an amount.
    3. To with draw and amount after checking the balance.
    4. To display name and balance.
    Yup, that'll get the economy back on an even keel, no toxic debt, sub prime. Just straightforward money in - money out. Sorted.

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    33
    hello,

    I have the same question but its not my assignment.I am doing it for my personal interest.The problem in doing this is that,I want to show the account details from account number,but how to assign account number to each account holder?My program runs only for single input not for an array.I have used classes in it.Can anyone tell me how to assign account number to each account holder if the user open an account?Is inheritance necessary for this problem?

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by salmanriaz View Post
    hello,

    I have the same question but its not my assignment.I am doing it for my personal interest.The problem in doing this is that,I want to show the account details from account number,but how to assign account number to each account holder?My program runs only for single input not for an array.I have used classes in it.Can anyone tell me how to assign account number to each account holder if the user open an account?Is inheritance necessary for this problem?
    No inheritance needed. You want some type of Bank class that can CreateAccount()'s and CloseAccount()'s for customers. The BankAccount that has customer information will also include the accountNumber, and the Bank can store a map of BankAccount's keyed by accountNumber.

  9. #9
    Registered User
    Join Date
    Mar 2009
    Posts
    33
    Thanx medievalelks problem done but only for single account.If I create two or more accounts,then function(details) in my code show the last entry.I know array should be used here but how?I dont want to use linked list.Here is my code for single account.

    Code:
    # include<iostream>
    # include<string.h>
    
    using namespace std;
    
    
    int choice;
    class bank{
          
          private:
                  int age,balance,accountnumber,amount;
                  string name,occupation,address;
    
            static int account;      
    
          public:
                 int accountno;
                 bank(){};
                 ~bank(){};
                 void open();
                 void deposit();
                 void withdraw();
                 void details();
                 
                 
                 
    };   
    
    
                          
               
     int bank::account=1000;          
               
                 void bank::open()
                 {
                      cout<<"Enter name\n";
                      cin>>name;        
                      cout<<"Enter age\n";
                      cin>>age;        
                      cout<<"Enter occupation\n";
                      cin>>occupation;        
                      cout<<"Enter address\n";
                      cin>>address;        
                      do{
                      cout<<"Enter balance to start account\n";
                      cin>>balance;        
                      }
                      while(balance<1000);
                      
                      accountno=++account;
                      
                      cout<<"ACCOUNT NUMBER:"<<accountno<<endl;
                      
                 }
                 
                 void bank::deposit()
                 {
                      cout<<"Enter account number\n";
                      cin>>accountnumber;
                      
                      if (accountnumber==accountno)
                      {
                         cout<<"Enter amount of balance to deposit\n";
                         cin>>amount;
                         
                         balance=balance+amount;
                         
                      }
                      
                     else
                     
                     cout<<"Invalid account number\n";
                 }   
                                                                                                            
                      
                 void bank::withdraw()
                 {
                      cout<<"Enter account number\n";
                      cin>>accountnumber;
                      
                      if (accountnumber==accountno)
                      {
                         cout<<"Enter amount of balance to withdraw\n";
                         cin>>amount;
                         
                         balance=balance-amount;
                         
                      }
                      
                     else
                     
                     cout<<"Invalid account number\n";
                 }   
                                                                                                            
                
                 void bank::details()
                 {
                      cout<<"Enter account number\n";
                      cin>>accountnumber;
                      
                      if (accountnumber==accountno)
                      {
                        cout<<"NAME:"<<name<<endl;
                        cout<<"AGE:"<<age<<endl;
                        cout<<"OCCUPATION:"<<occupation<<endl;
                        cout<<"ADDRESS:"<<address<<endl;
                        cout<<"BALANCE:"<<balance<<endl;
                     }
                     
                     else
                     
                     cout<<"Invalid account number\n";
                 }
                 
                                       
                      
                                                     
    int main()
    {
        bank b;
     
       start:
             
              system("cls");
        
        cout<<"What do you want to do\n";
       
        cout<<"1.To open account\n";
        cout<<"2.To deposit balance in account\n";
        cout<<"3.To withdraw balance in account\n";
        cout<<"4.To see details of account\n";
        cout<<"5.Exit\n";
        
       cout<<"Your choice\n";
       cin>>choice;
       
       switch (choice){
              
              case 1:{b.open();       
                      system("pause");                
                      break;
                      };
              case 2:{b.deposit();
                      system("pause");         
                      break;
                      };
              case 3:{b.withdraw();
                      system("pause");         
                      break;
                      };
              case 4:{b.details();
                      system("pause");         
                      break;
                      };
              case 5:{exit(0);
                      system("pause");         
                      break;
                      };
              default:cout<<"Invalid input\n";
         };
         goto start;
    
        
      
    
    
    
     
      system("pause");
      
      return 0;
      
    }

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    I would rename your bank class to account, since that's really what it is. Then, create the bank class to hold multiple accounts, using a std::map as the container (not an array).

    The std::string key of the map could be account number:

    Code:
    std::map<std::string, boost::shared_ptr<account> > accounts;
    If you don't want to download Boost and learn about shared_ptr's just yet, just use a raw pointer:

    Code:
    std::map<std::string, account *> accounts;
    I'll let you Google std::map (or use the link in my other post :-)).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 12:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 06:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 04:35 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21