Banking Management System:


Code:



#include <iostream>
#include<fstream>
#include<cstdlib>

int n;

using namespace std;
class Account;
class Bank
{
    protected:
static int std_id;
string Name;
string Account_number;
string type;
int deposit;
string phone;
int id;
int pay;
int room;
string jobSpec;
string subject;
public:
    string bank_name;
    int branch_code;
    string branch_location;

    void get_detail()
    {
        cout<<"Enter name of the bank:__";
        cin>>bank_name;
        cout<<"Enter branch code:__";
        cin>>branch_code;
        cout<<"Enter branch location:__";
        cin>>branch_location;
    }
    void display()
    {
        cout<<"Bank Name:         "<<bank_name<<endl;
        cout<<"Branch Code:       "<<branch_code<<endl;
        cout<<"Branch Location:   "<<branch_location<<endl;
    }

};
class User
{
    public:
    string e_mail;
    int Password;

    void get_input()
    {
        cout<<"Enter User Name:  "<<endl;
        cin>>e_mail;
    do
    {
        cout<<"Enter Password:   "<<endl;
        cin>>Password;

    {


        switch(Password)
        {
        case 2020105041:
        (Password==2020105041);
         cout<<"****************Access granted********************"<<endl;
         cout<<"Umer\n ";
         cout<<"Account number = f2020105041 \n";
         cout<<"Account type : Current \n";
         cout<<"Balance Amount is :10000 ";
         break;
        case 2020105039:
            (Password==2020105039);
        cout<<"****************Access granted********************"<<endl;
        cout<<"Khan\n ";
         cout<<"Account number = f2020105039 \n";
         cout<<"Account type : Current \n";
         cout<<"Balance Amount is :10000 ";
        break;
        case 2020105007:
        (Password==2020105007);
        cout<<"****************Access granted********************"<<endl;
        cout<<"Abdul\n ";
         cout<<"Account number = f2020105007 \n";
         cout<<"Account type : Saving \n";
         cout<<"Balance Amount is :10000 ";
    break;
      case 2020105047:
        (Password==2020105047);
        cout<<"****************Access granted********************"<<endl;
        cout<<"Ali\n ";
         cout<<"Account number = f2020105047 \n";
         cout<<"Account type : Saving \n";
         cout<<"Balance Amount is :10000 ";
         break;
    }

    }
    }while(Password!=2020105041 && 2020105039 && 2020105007 && 2020105047 );
    }
    void display()
    {
        cout<<"\n\n\t\t\t1:card      :"<<endl;
        cout<<"\t\t\t2:cheque    :"<<endl;
        cout<<"\t\t\t3:billing   :"<<endl;
    }
};
class Account
{
    public:
        User us;
    Account();
Account( string Account_number, string Name, string type,int deposit);
void account();
void disp()
{
         cout<<"\t\t\t\t\t\tall account Holder list is \n\n\n"<<endl;
         cout<<"Account :1"<<endl;
         cout<<"Umer \n ";
         cout<<"Account number = f2020105041 \n";
         cout<<"Account type : Current \n";
         cout<<"Balance Amount is :10000 ";
         cout<<"\n\n\nAccount :2"<<endl;
         cout<<" Khan \n ";
         cout<<"Account number = f2020105039 \n";
         cout<<"Account type : Current \n";
         cout<<"Balance Amount is :10000 ";
         cout<<"\n\n\nAccount :3"<<endl;
         cout<<"Abdul\n ";
         cout<<"Account number = f2020105007 \n";
         cout<<"Account type : Saving \n";
         cout<<"Balance Amount is :10000 ";
}
void disp_spe()
{

        us.get_input();
}


};
Account::Account(){
}
Account::Account( string Account_number, string Name, string type,int deposit){
Name =Name;
Account_number = Account_number;
type= type;
deposit = deposit;
}



class card :public Account
{
   public:
       int card_pin;
       int total_balance=10000;
       card()
       {
           card_pin=0;
       }
       friend ostream& operator << (ostream& q,card c1)
       {
           q<<"pleas enter the card pin code"<<endl;

       }
       friend istream& operator >> (istream& q,card c1)
       {
           q>>c1.card_pin;

       }
       void fun()
       {

            cout<<"enter the password "<<endl;
             cin>>card_pin;
            if(card_pin==1234)
    {
        cout<<"access "<<endl;
        cout<<"\t\t\tWELCOME TO ATM"<<endl;
        cout<<"\t\t\t1:Withdraw"<<endl;
        cout<<"\t\t\t2:Deposit"<<endl;
        cout<<"\t\t\t3:Exit";
    }
    else if(card_pin!=1234)
    {
        do
        {
        cout<<"Wrong password try again"<<endl;
        cin>>card_pin;

        }while(card_pin!=1234);
        cout<<"access "<<endl;

        cout<<"\t\t\tWELCOME TO ATM"<<endl;
        cout<<"Select your choice "<<endl;
        cout<<"\t\t\t1:Withdraw"<<endl;
        cout<<"\t\t\t2:Deposit"<<endl;
        cout<<"\t\t\t3:Exit"<<endl;
    }

{
    int y;
    cout<<endl;
    cin>>y;
    switch(y)
    {
    case 1:
    cout<<"how much money what do you want to withdraw "<<endl;
    cout<<"1.500"<<endl;
    cout<<"2.1000"<<endl;
    cout<<"3.5000"<<endl;
    cout<<"4.10000"<<endl;
    cout<<"5.Enter your money"<<endl;


    int u;
    cin>>u;
    if(u==1)
    {
        total_balance-=500;
        cout<<"your with draw balance is 500"<<endl;
        cout<<"now your remaining balance is "<<total_balance<<endl;
    }
    else if(u==2)
    {
         total_balance-=1000;
        cout<<"your with draw balance is 1000"<<endl;
        cout<<"now your remaining balance is "<<total_balance<<endl;
    }
    else if(u==3)
    {

         total_balance-=5000;
        cout<<"your with draw balance is 5000"<<endl;
        cout<<"now your remaining balance is "<<total_balance<<endl;
    }
    else if(u==4)
    {

         total_balance-=10000;
        cout<<"your with draw balance is 10000"<<endl;
        cout<<"now your remaining balance is "<<total_balance<<endl;
    }
    else if(u==5)
    {
        int i;
        cout<<"enter your withdraw money"<<endl;
        cin>>i;
        if(total_balance>=i)
        {
             total_balance-=i;

            cout<<"your withdraw money is"<<i<<endl;
            cout<<"your remaining balance is"<<total_balance<<endl;

        }
        else
        {
           cout<<"not enough money in your account \n";
        }
    }
    break;
    case 2:
        cout<<"\t\t how much money did you deposit in your account "<<endl;
        cout<<"\t\t 1:500"<<endl;
        cout<<"\t\t 2:1000"<<endl;
        cout<<"\t\t 3:5000"<<endl;
        cout<<"\t\t 4:10000"<<endl;
        cout<<"\t\t 5:enter your choice"<<endl;
        int u2;
        cin>>u2;
        if(u2==1)
        {
            cout<<"before deposit your balance is 500"<<endl;
            total_balance+=500;
            cout<<" After deposit your total balance is :"<<total_balance<<endl;
        }
        else if(u2==2)
        {
             cout<<"before deposit your balance is 1000"<<endl;
            total_balance+=1000;
            cout<<"After deposit your total balance is :"<<total_balance<<endl;
        }
        else if(u2==3)
        {
             cout<<"before deposit your balance is 5000"<<endl;
            total_balance+=5000;
            cout<<"After deposit your total balance is :"<<total_balance<<endl;
        }
    else if(u2==4)
{
         cout<<"before deposit your balance is 10000 "<<endl;
            total_balance+=10000;
            cout<<"After deposit your total balance is :"<<total_balance<<endl;
}
    else if(u2==5)
{
    cout<<"enter your money"<<endl;
    int m;
    cin>>m;
    cout<<"before deposit your balance is :"<<total_balance<<endl;
    total_balance+=m;
    cout<<"after deposit your balance is :"<<total_balance<<endl;
    break;
    case 3:
        exit(0);
}
}
}
       }
};
class cheque:public card
{
public:
    int cheque_number;
    int ammount;
    int issue_date;
    int expire_date;
public:
    void reqforcheque()
    {
        cout<<"press 1 for cheque book \n  ";
        cout<<"press 2 for exit  \n";
         int b;
        cin>>b;
        if(b==1)
        {

        int choice ;
    double amount;
    double totalServiceCharge;
    double serviceCharge = .25;
    double numService = 0;

    cout<<fixed<<showpoint;

    cout<<"Checkbook Balancing program"<<endl;
    cout<<" your beginning balance: "<<total_balance;
    cout<<endl;

    while (choice != 3)
    {
        cout<<"Pleas select your option"<<endl;
        cout<<"1 - Process a Check."<<endl;
        cout<<"2 - Process a Deposit."<<endl;
        cout<<"3 - Do end of month processing and exit program."<<endl;

        cout<<"Transaction type: ";
        cin>>choice;

        if (choice == 1 )
        {
            cout<<"Enter transaction amount: ";
            cin>>amount;
            cout<<"Processing check for "<<amount<<endl;
            total_balance = total_balance - amount;
            cout<<"Balance: "<<total_balance<<endl;
            cout<<"Service charge: $"<<serviceCharge<<" for a check"<<endl;
            numService++;
            totalServiceCharge = numService * serviceCharge;
            cout<<"Total service charges: $"<<totalServiceCharge<<endl;
        }

        else if (choice == 2)
        {
            cout<<"Enter transaction amount: ";
            cin>>amount;
            cout<<"Processing deposit for "<<amount<<endl;
            total_balance = total_balance + amount;
            cout<<"Balance: "<<total_balance<<endl;
            totalServiceCharge = numService * serviceCharge;

            cout<<"Total service charges: $"<<totalServiceCharge<<endl;
        }
        else if (choice == 3)
        {
            cout<<"Processing end of the month "<<endl;
            totalServiceCharge = numService * serviceCharge;
            cout <<"Final Balance: "<<total_balance - totalServiceCharge<<endl;
        }
        else
        {
            cout<<"Please enter a valid transaction type"<<endl;
        }
    }

        }
        else if(b==2)
        {
            exit(0);cout<<"Umer\n ";
         cout<<"Account number = f2020105041 \n";
         cout<<"Account type : Current \n";
         cout<<"Balance Amount is :10000 ";
        }
    }
};
class billing:public Account
{
public:
    string name;
    int bill_id;
    int bill_ammount;
    char bill_date;
public:
    billing()
    {
        cout<<"Select bill you want to pay "<<endl;
         cout<<"\n\n\t\t\t1: Electricity "<<endl;
         cout<<"\t\t\t2: Gas "<<endl;
         cout<<"\t\t\t3: Water "<<endl;
    }
    void input_det()
    {

        cout<<"enter the customer name :";
        cin>>name;
        cout<<"enter bill id           :";
        cin>>bill_id;
        cout<<"enter the bill amount   :";
        cin>>bill_ammount;
        cout<<"enter the bill date     :";
        cin>>bill_date;
    }
    void paybill(Account as)

    {
        cout<<"bill amount is"<<endl;
    }

};
int main()
{
    int n;
    do
    {

    cout<<"\n\n\t\t\t1:Bank Data:"<<endl;
    cout<<"\t\t\t2:Accounts:  "<<endl;
    cout<<"\t\t\t3:User LOGIN:"<<endl;


    cout<<"Enter value from Menu:"<<endl;
    cin>>n;
    Bank b1[6];
    User u1;
    Account a1;
    card c1;
    cheque ce;
    if(n==1)
    {
    int a;
    cout<<"\t\t\tPress 1 to Write data in file:"<<endl;
    cout<<"\t\t\tPress 2 to read data from file:"<<endl;
    cin>>a;
    if(a==1)
    {
        int i;
        fstream file;
   file.open("Banks_data.txt", ios :: out);
    cout << "Enter Data to write file:- " << endl;
   for (i = 0; i <=4; i++)
    {
    cout<<"Enter data for Bank:  "<<i+1<<endl;
    b1[i].get_detail();
      file.write((char *)&b1[i], sizeof(b1[i]));
    }
   file.close();
    }
    else if(a==2)
    {
        fstream file;
file.open("Banks_data.txt", ios :: in);
   cout << "\nData on file is:-\n" << endl;

   for (int i = 0; i <=4 ; i++)
    {
      file.read((char *)&b1[i], sizeof(b1[i]));
      cout<<"Branch:  "<<i+1<<endl;
      b1[i].display();
    }
   file.close();
    }
    }
        else if(n==2)
        {
            cout<<"\t\t 1:  show all accounts "<<endl;
            cout<<"\t\t 2:  show account "<<endl;
            cout<<"\t\t 3:  Enter value from Menu"<<endl;
            cin>>n;
            if(n==1)
            {
            a1.disp();
            }
            else if(n==2)
            {
            a1.disp_spe();
            }


        }

    else if(n==3)
        {

      u1.get_input();
      u1.display();
      cout<<"Enter number from Menu:"<<endl;
      cin>>n;
      if(n==1)
      {
      c1.fun();
      }
      else if(n==2)
      {
          ce.reqforcheque();
      }
      else if(n==3)
      {
          billing b1;
          b1.input_det();
      }

        }

   else if(n==6)
   {

   }
    }while(n!=8);

    return 0;
}