Banking Management System Project in C++

//preprocessor directive section

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<dos.h>
#include<graphics.h>
#include<process.h>
#include<iomanip.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdio.h>

//class section

class bank   //create class bank
{
public:                      //access specifier public
long int acno,am,n,m,bal,mn;
char  ph[12];
char type,C,S;

int day,month,year;
char name[20],fname[12];
 //********************************************************//

      void create()    //function to create a account
   {

    cout<<"\n\t\t Enter Account no                     : ";
    cin>>acno;

cout<<"\n\t\t Enter the Name of the Account Holder : ";
cin>>name;
cout<<"\n\t\t Enter the type of Account (C/S)      : ";
cin>>type;

  cout<<"\n\t\t Enter Date of Birth                  : ";
  cin>>day;
  cin>>month;
  cin>>year;

  cout<<"\n\t\t Enter Contact number                 : ";
  cin>>ph;

    cout<<"\n\t\t Enter Amount (S>=500) or (C>=1000)   : ";
    cin>>bal;

cout<<"\n\t\t Account Created. : ";

  delay(500);

}
  //*********************************************************//

    void display()     //used for display details of account
   {

   cout<<"\n\n\n\n\t\t\t  Your account no is           : "<<acno;
      cout<<"\n\n\t\t\t  Name of the Account Holder   : "<<name;
      cout<<"\n\n\t\t\t  Type of Account              : "<<type;

      cout<<"\n\n\t\t\t  Date of Birth                : ";
cout<<day<<""<<month<<""<<year;

cout<<"\n\n\t\t\t  Contact Number               : "<<ph;


      cout<<"\n\n\t\t\t  Your AC Balance is           : "<<bal;

  }
  //************************************************************//

     void modify()        //used for modifying a account
       {

cout<<"\n\n\t\t\t Enter your new name           : ";
cin>>name;
  cout<<"\n\n\t\t\t Enter your new contact no.    : ";
  cin>>ph;



      }
       //*********************************************************//
void deposit()        //used for deposit balance in account
{

 cout<<"\n\n\n\t\t\t Enter balance                 : ";
cin>>am;
      bal=am+bal;
cout<<"\n\n\t\t\t After Deposit Your Balance is : "<<bal;

      }
      //********************************************************//


     void withdraw()    //withdraw function for withdrawing balance
  {


    cout<<"\n\n\t\t\t Enter Amount                    : ";
     cin>>am;
     if(bal<am)
     {
     cout<<"\n\n\t\t\t Not Enough Balance ";
     }
     else
     {
    bal=bal-am;
    cout<<"\n\n\t\t\t After Withdrawl Your Balance is : "<<bal;
   }
   }
   //**************************************************************//

   long int  ret1()
     {
       return acno;         //return account no
    }
  //******************************************************************//

long int ret2()
    {
     return am;               //return ammount
   }

 //********************************************************************//

 void  report()
{
cout<<"\t"<<acno<<setw(12)<<" "<<name<<setw(14)<<" "<<type<<setw(15)<<bal<<endl;
 }
  //*******************************************************************//
   void project()
   {

   cout<<"\n\n\n\t The project has been made  in  order  to  facilitate  the  entire";
   cout<<"\n\n\t working  of  a  bank.  Here we have divided the work in different";
   cout<<"\n\n\t section, each  performing  a specific  task. The  BANK MANAGEMENT";
   cout<<"\n\n\t SYSTEM undertaken as a project is based  on relevant technologies";
   cout<<"\n\n\t The  aim  of  the bank management  system is  an application  for\n\n\t maintaining ";
   cout<<"a person's account in a bank . ";
   cout<<"\n\n\t The system has the following interface choose : ";
   cout<<"\n\n\t 1. CREATE A NEW ACCOUNT ";
   cout<<"\n\t 2. DISPLAY ACCOUNT DETAILS ";
   cout<<"\n\t 3. MODIFY ACCOUNT   ";
   cout<<"\n\t 4. DEPOSIT ";
   cout<<"\n\t 5. WITHDRAW ";
   cout<<"\n\t 6. DISPLAY ALL ACCOUNTS";
char z;
   cout<<"\n\n\n\t\t\t   ";
   cin>>z;

   clrscr();



   cout<<"\n\n\t\t\t This Project is Created By : ";

   cout<<"\n\n\t\t\t Name                : Akashdeep Singh ";
   cout<<"\n\n\t\t\t Rollno                   : 20709";
   cout<<"\n\n\t\t\t Class                    : BCA - 4th Sem.";

   }




 };           //closing a class

  void write1();       //Global Declaration of write()
  void display1(long int);
  void display2();

 void deposit1(long int n,long int op);

 void modify1(long int n);







    long int main() //function main()

    {
       textbackground(15);
 clrscr();                 //clrscr() used to clear a output screen
 bank a1;                  //Create object of bank class
 long int ch,g;
 long int num;               //local declaration




cout<<"\n\n\n\n\n\t\t\t\t";
textcolor(1);
       delay(300);
      cout<<" W";
       delay(300);
      cout<<"E";
       delay(300);
      cout<<"L";
       delay(300);
      cout<<"C";
       delay(300);
      cout<<"O";
       delay(300);
      cout<<"M";
       delay(300);
      cout<<"E";
      delay(500);


  cout<<"\n\n\n\n\n\t\t\t Banking  Management System ";
 delay(2000);
   clrscr();

      cout<<"\n\n\n\n\t\t ACKNOWLEDGEMENT : ";
 cout<<"\n\n\n\n\n\t\t First and Foremost I thanks my Teachers and Friends \n\n\t\t who helped  me in my Project . Without there  help\n\n\t\t I would not be able to make it.";




      delay(8000);

    pn:                      //create label for goto statement
  clrscr();
textbackground(15);
textcolor(1);
  cout<<"\n\n\n\t\t\t*******MAIN MENU*******";

  delay(150);
 cout<<"\n\n\t\t\t 1. Create a New Account";

 delay(150);
 cout<<"\n\n\t\t\t 2. Display Created Account";

 delay(150);
 cout<<"\n\n\t\t\t 3. Modify Account";

 delay(150);
 cout<<"\n\n\t\t\t 4. Deposit Balance ";

 delay(150);
 cout<<"\n\n\t\t\t 5. Withdraw a Balance";

 delay(150);
 cout<<"\n\n\t\t\t 6. Show All Accounts  ";
 delay(150);
 cout<<"\n\n\t\t\t 7. About This Project";
 delay(150);
 cout<<"\n\n\t\t\t 8. EXIT ";

 delay(150);
 cout<<"\n\n\n\t\t\t Enter your choice : ";
 cin>>ch;

 switch(ch)               //switch statement
 {
 case 1:                    //case 1

 clrscr();                //clrscr() used to clear a output screen
 //a1.create();                //accessing create ()
 write1();

     delay(800);
 cout<<"\n\n\n\t\t\t\t Press 2 key to back  ";

 cin>>g;
 if(g==2)
 {

 goto pn;             //goto statement
 }
   break;               //break statement


 case 2:

   clrscr();
   cout<<"\n\n\t\t\t Enter account number : ";
   cin>>num;
display1(num);  //clrscr() used to clear a output screen
// a1.display();
 delay(2000);
 cout<<"\n\n\n\t\t\t     Press 2 key to back  ";
 cin>>g;
 if(g==2)
 {

 goto pn;
 }


 break;

 case 3:

 clrscr();
  cout<<"\n\n\t\t\t Enter The account No.          : ";
   cin>>num;    //clrscr() used to clear a output screen
 modify1(num);
 delay(800);
 cout<<"\n\n\n\n\n\n\n\t\t\t\t Press 2 key to back  ";
 cin>>g;
 if(g==2)
 {

 goto pn;
 }
 break;                      //break statement

 case 4:

 clrscr();                   //clrscr() used to clear a output screen
 cout<<"\n\n\t\t\t Enter The account No.         : ";
  cin>>num;
 deposit1(num,1);
 delay(800);
 cout<<"\n\n\n\n\n\n\t\t\t\t Press 2 key to Main Menu : ";
 cin>>g;
 if(g==2)                   //if statement used for single condition. if(g==2) the control goes to pn label
 {
 goto pn;
 }
 break;

 case 5:

 clrscr();
  cout<<"\n\n\t\t\t Enter The account No.          : ";
   cin>>num;
 deposit1(num,2);
delay(800);

 cout<<"\n\n\n\n\n\n\n\t\t\t Press 2 key to Main Menu : ";
 cin>>g;
 if(g==2)            //if statement
 {

 goto pn;            //goto pn label
 }
 break;

 case 8:
 exit(0);           //exit function for exit

    break;


case 7:
clrscr();
a1.project();


   delay(2000);
 cout<<"\n\n\n\t\t\t     Press 2 key to back  ";
 cin>>g;
 if(g==2)
 {
 goto pn;
 }
  break;

  case 6:

  clrscr();
  display2();

   cout<<"\n\n\n\n\n\t\t\t\t     Press 2 key to back  ";
 cin>>g;
 if(g==2)
 {
 goto pn;
 }
  break;


 default:

 clrscr();
 cout<<"\n\n\n\n\t\t\t\t Invalid  Option";

    delay(1000);
    textcolor(5);
    {
 cout<<"\n\n\n\n\n\t\t\t\t Press 2 key to back  ";
 }
 cin>>g;
 if(g==2)
 {
 goto pn;             //goto statement
 }
 }






 getch();
   return 0;
   }        //return  value to os


//*********************************************************************************** //

void write1()
{
bank b1;
ofstream fl;
fl.open("bank.dat",ios::binary|ios::app);
b1.create();
fl.write((char *) &b1, sizeof(bank));
fl.close();
}
//***************************************************************
//         function to read record
//****************************************************************

void display1(long int n)
{
bank b1;
int as=1;
ifstream fl;
fl.open("bank.dat",ios::binary);
if(!fl)
{
cout<<"\n\n\n\n\t\t\tFile  not found ";
return;
}
       cout<<"\n\t\t\t****ACCOUNT   DETAILS****\n";
while(fl.read((char *) &b1, sizeof(bank)))
{
if(b1.ret1()==n)
      {
      b1.display();

      }
     // if(b1.ret1()!=n)
    // else

   // cout<<"\n\t\t\t ACCOUNT IS NOT AVAILABLE\n";

      }
fl.close();
if(as==0)

cout<<"\n\n\t\t\t Invalid Account Number";
}


// **************** function to display all Accounts *************//


void display2()
{
bank b1;
ifstream fl;
fl.open("bank.dat",ios::binary);
if(!fl)
{
cout<<"\n\n\n\n\t\t\tNo Account Found ";
return ;
}
cout<<"\n\n\t\t\tACCOUNT HOLDER LIST\n\n";
cout<<"\t=========================================================\n";
cout<<"\tA/c no.        NAME            Type            Balance\n";
cout<<"\t=========================================================\n";
while(fl.read((char *) &b1, sizeof(bank)))
{
b1.report();
}
fl.close();
}

 // *******************************************************************//
  void deposit1(long int n ,long int op)
{
int amt;
int fd=0;
bank b1;
fstream fl;
fl.open("bank.dat", ios::binary|ios::in|ios::out);
if(!fl)
{

return;
}
while(fl.read((char *) &b1, sizeof(bank)) && fd==0)
{
if(b1.ret1()==n)
{

if(op==1)
{


b1.deposit();
}
if(op==2)
{

 b1.withdraw();
    }
int pos=(-1)* sizeof(b1);
fl.seekp(pos,ios::cur);
fl.write((char *) &b1, sizeof(bank));
cout<<"\n\n\t\t\t  Account Updated";
fd=1;
      }
}
fl.close();
if(fd==0)
cout<<"\n\n\t\t\t Account Not Found ";
}
void modify1(long int n)
{
int fd=0;
bank b1;
fstream fl;
fl.open("bank.dat",ios::binary|ios::in|ios::out);
if(!fl)
{
cout<<"\n\n\t\t\t NOT  FOUND ";
return;
}
while(fl.read((char *) &b1, sizeof(bank)) && fd==0)
{
if(b1.ret1()==n)
{
//ac.show_account();
cout<<"\n\t\t\t Enter New Details "<<"\n";
b1.modify();
int pos=(-1)*sizeof(bank);
fl.seekp(pos,ios::cur);
fl.write((char *) &b1, sizeof(bank));
cout<<"\n\n\n\t\t\t\t Account Updated";
fd=1;
}
}
fl.close();
if(fd==0)
cout<<"\n\n\t\t\t Record Not Found ";
}



2 comments: