Bank Management System in C++

This Program of Bank Management in System in C++ are example of array of object, so to understand this program, you can take help of this program.


Demo of Bank Management System in C++

In the program, the first option CREATE ACCOUNT will be used to create account then other option will be, as you can see in the diagram,

banking-management-system-in-cpp

Here, creating an account means how many class objects have been declared.
In the program, we have defined the size of the array-object 6,

banking obj[6];

Here banking is class name and obj[] is an array type object of this class.

So this means that we can create 6 customer account or less here

Here is the program,

#include<iostream.h> 
#include<conio.h>
#include<stdio.h> //gets() and puts()
#include<stdlib.h> //exit()
class banking
{
  // by default member are private
   int amount,ac_number;
   char cust_name[20],ac_type;
 public:
 // member are public
   void get_record();
   friend void show_record(banking); // displaying customer record
   int re_amount();  // to return spacific customer amount
   int re_account(); // to return spacific customer account
   int deposit();    // deposit into account
   int withdraw();   // withdraw from account
};
 // storing data from user
    void banking::get_record()
      {
	 cout<<"Enter Account No: ";
	 cin>>ac_number;
	 cout<<"Enter the Name: ";
	 gets(cust_name);
	 cout<<"Enter the Account type(CS): ";
	 cin>>ac_type;
	 cout<<"Enter the Amount: ";
	 cin>>amount;
      }
     // return amount a specific customer
     int banking::re_amount()
     {
      return(amount);
     }
// using friend function to displaying customer record so not need to :: operator for defination
    void show_record(banking obj)
    {
       // obj can access private member of same class
       cout<<"Account No : "<<obj.ac_number<<"n";
       cout<<"Name : ";puts(obj.cust_name);
       cout<<"Account Type : "<<obj.ac_type<<"n";
       cout<<"Amount : "<<obj.amount<<"n";
    }
   // return account a customer
   int banking::re_account()
   {
      return(ac_number);
   }
  int banking::deposit()
  {
     int d;
     cout<<"Enter the ammount to be deposit: ";
     cin>>d;
     amount = amount+d;
     return amount;    // return total depsit in account
  }
  int banking::withdraw()
  {
     int w;
     if(amount<500)
     {
      cout<<endl;
      cout<<"Sorry! Insuficient Balance transection not available";}else{
      cout<<"nEnter the ammount to be withdraw: n";
      cin>>w;
      amount = amount-w;
      cout<<"amount successfully withdraw";
     }
     return amount; // return wiithdraw amount
    }
// starting main function
void main()
{
     clrscr();
     banking x[6];      //that means we can store 6 customer at a time.
     int ch,count,account,amount;
  do{
	start:
	cout<<"nnntttt****BANKING****nn";
	cout<<"tttt1.CREATE ACCOUNTnn";
	cout<<"tttt2.DEPOSITnn";
	cout<<"tttt3.WITHDRAWnn";
	cout<<"tttt4.DISPLAY ALL ACCOUNTnn";
	cout<<"tttt5.SEARCHnn";
	cout<<"tttt0.EXITnnnn";
	int n=0;
	while(n<80)
	{
	 cout<<"_";n++;  // printing a line
	}
	cout<<endl;
	cout<<"tttttEnter Your Choice: ";
	cin>>ch;
	switch(ch)
	{
	case 1: clrscr();
		int cust;
		cout<<"How Many Customer Record you want to Store: ";
		cin>>cust;
		for(count=0;count<cust;count++)
		{
		  cout<<count+1<<". ACCOUNTn";
		  x[count].get_record();  // get_record function calling
		  cout<<"nn";
		  cout<<"Account Created Successfully";
		  getch();
		  clrscr();
		}
		break;
	case 2: clrscr();
		int true=0;
		cout<<"nEnter the Account No:";
		cin>>account;
		for(count=0;count<cust;count++)
		{
		 if(account==x[count].re_account())
		 {
		   x[count].deposit(); // deposit function calling
		   cout<<"Amount Successfully Deposit";
		   getch();
		   clrscr();
		   true=1;
		 }
		}
		if(!true)
		{
		  cout<<"Account Not Found";
		  getch();
		  clrscr();
		}
		break;
      case 3:  clrscr();
		int right=0;
		cout<<"nEnter the account No:";
		cin>>account;
		for(count=0;count<cust;count++)
		{
		 if(account==x[count].re_account())   // check account match or not
		 {
		   x[count].withdraw();
		   getch();
		   clrscr();
		   right=1;
		 }
		}
		if(!right)
		{
		 cout<<"Account Not Found";
		 getch();
		 clrscr();
		}
		break;
      case 4:  clrscr();
		int a;
		cout<<"tALL ACCOUNT DISPLAY:n";
		cout<<"==================================n";
		for(count=0;count<cust;count++)
		{
		 if(x[count].re_account()==0)
		    return;
		 cout<<count+1<<". ACCOUNTn";
		 cout<<"--------------------------------------n";
		 show_record(x[count]);   // display all account record
		 cout<<"=====================================n";
		 getch();
		}
		clrscr();
		break;
      case 5:  clrscr();
		int search,correct=0;
		cout<<"nEnter account No. to be search: ";
		cin>>search;
		for(count=0;count<cust;count++)
		{
		 if(search==x[count].re_account())
		 {
		   cout<<endl<<count+1<<". ACCOUNTn";
		   show_record(x[count]);   // display search account detail
		   getch();
		   correct=1;
		   clrscr();
		 }
		}
		if(!correct)  {
		   cout<<"nThis Acount Not Available....Try Again.";
		   getch();
		   clrscr();
		   goto start;
			      }
		   break;
      case 0:  exit(0);
	      break;
      default: cout<<"Invalid Choice";
		clrscr();
		goto start;
	}
  }while(ch!=0);
}
OUTPUT:-
                    ****BANKING****
                    1.CREATE ACCOUNT
                    2.DEPOSIT
                    3.WITHDRAW
                    4.DISPLAY ALL ACCOUNT
                    5.SEARCH
                    0.EXIT
_________________________________________________________________

Download and execute program by yourself,


Related Project in C++ are: