Saturday, 18 February 2017

Class of bank management with password

In this program we will create a class of bank management system to access the system user needs to enter password then the result of deposit and withdraw will be shown at the end.
The code is given below.

//Code starts
#include<iostream>
#include<conio.h>
using namespace std;

class account{
         
          private:
              int bal,dep,withdraw,acno;
              char name[100];
             
              public:
                   
                    int setbal();
                    int setdep();
                    int setwithdraw();
                    int setacno();
                    char setname();
                   
                    int getbal();
                    int getdep();
                    int getwithdraw();
                    int getacno();
                    char* getname();
                   
                    void display();
                   
};

char account::setname()
{
          cout<<"Enter your name : "<<endl;
          cin>>name;
}

int account::setacno()
{
          cout<<"Enter your Account Number: "<<endl;
          cin>>acno;
}

int account::setbal()
{
          cout<<"Enter Your Account Balance: "<<endl;
          cin>>bal;
}

int account::setdep()
{
          cout<<"Enter Amount to be deposite : "<<endl;
          cin>>dep;
}

int account::setwithdraw()
{
          cout<<"Enter Ammount to be withdraw :"<<endl;
          cin>>withdraw;
}

char* account::getname()
{
          return name;
}

int account::getacno()
{
          return acno;
}

int account::getbal()
{
          return bal;
}

int account::getdep()
{
          return dep;
}

int account::getwithdraw()
{
          return withdraw;
}

void account::display()
{
          cout<<"Name : "<<getname()<<endl;
          cout<<"A/C No :  "<<getacno()<<endl;
          cout<<"Balance : "<<getbal()<<" RS "<<endl;
          cout<<"Deposte : "<<getdep()<<" RS "<<endl;
          cout<<"Withdraw :  "<<getwithdraw()<<" RS "<<endl;
}

int main()
{    
       int pass,a,b;
      
         
          account a1;
abc:   cout<<"Enter Password: "<<endl;
                    cout<<"Hint: 12345"<<endl;
                    cin>>pass;
         
          if(pass==12345)
{

cout<<"Welcome to Bank Management System: "<<endl;

}
else{
          cout<<"Re-enter Password:  "<<endl;
          goto abc;
}

          a1.setname();
          a1.setacno();
          a1.setbal();
          a1.setdep();
          a=a1.getbal()+a1.getdep();
          cout<<"Amount after deposite : "<<a<<" RS."<<endl;
         
def:    a1.setwithdraw();
                   
          if(a1.getwithdraw()>a)
          {
                    cout<<"Enter amount less than "<<a<<" RS. "<<endl;
                    goto def;
          }
          else{
                    b=a-a1.getwithdraw();
                              cout<<"Amount after withdraw : "<<b<<" RS."<<endl;
          }

         
    cout<<"===============OUTPUT=================="<<endl;

a1.display();

getch();


}

OUTPUT:




Share:

0 comments:

Post a Comment