Menu-Driven Program for Bank Management System

Prerequisite: Switch Case in C/C++

Problem Statement:
Write a program to build a simple Bank Management System using C++ which can perform following operations:

  1. Open account
  2. Deposit Money
  3. Withdraw Money
  4. Display Account

Approach: Below is the approach to do the above operations:

  1. Open Account: This method takes details from the customer like name, address, type of account, and depositing money and creating new account.
    // Method to Open a new account.
    
    void Bank::open_account()
    {
        // Enter Name of a Customer
        name = "xyz Gupta";
    
        cout << "Enter your full name: "
             << name << endl;
    
        // Enter City of a Customer
        address = "Banglore";
        cout << "Enter your address: "
             << address << endl;
    
        // Enter Type of Account(Saving or Current)
        acc_type = 'S';
        cout << "Type of account you want "
             << "to open saving(S) or Current(C): "
             << acc_type << endl;
    
        // Enter Amount to deposit
        balance = 8000;
    
        cout << "Enter the amount for deposit: "
             << balance << endl;
        cout << "Account Created Successfully";
    }
    
  2. Deposit Money: Deposit money function is created to deposit money to the account by asking amount by the customer.
    It will ask the amount and add it to the available balance.
    Total Balance = Available Balance + Deposited Amount

    // Method to add balance in account
    
    void Bank::deposit_money()
    {
        int Amount;
    
        // Enter Amount to Deposit
        Amount = 9500;
        cout << "Enter How much money "
             << "you want to deposit: "
             << Amount << endl;
    
        // Total_Balance = Available_Balance + Amount
        balance += Amount;
        cout << "\Available Balance: "
             << balance;
    }
    
  3. Display Account: Display Account function will show the details of the customer like name, address, type of account and available balance.
    // Method to Display the details of account
    
    void Bank::display_account()
    {
        cout << "Name: " << name << endl
             << "Address: " << address << endl
             << "Type: " << acc_type << endl
             << "Balance: " << balance << endl
             << endl;
    }
    
  4. Withdraw Money: Withdraw money function is created to withdraw money from the account by asking amount by the customer.
    It will ask the amount and subtract it from the available balance.
    Total Balance = Available Balance - Withdrawal Amount

    
    void Bank::withdraw_money()
    {
        float amount;
    
        // Enter Amount to Withdraw
        amount = 3200;
        cout << "Enter How much money "
             << "you want to withdraw: "
             << amount << endl;
    
        // Total_Balance = Available_Balance - Withdrawal_Amount
        balance -= amount;
        cout << "Available balance: "
             << balance;
    }
    

Below is the implementation of the above approach:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to implement
// Bank Managaement System
  
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
using namespace std;
  
class Bank {
    string name, address;
    char acc_type;
    float balance;
  
public:
    void open_account();
    void deposit_money();
    void withdraw_money();
    void display_account();
};
  
// Function to open the account
void Bank::open_account()
{
    name = "Aman Jhurani";
    cout << "Enter your full name: "
         << name << endl;
    address = "Surat";
    cout << "Enter your address: "
         << address << endl;
    acc_type = 'S';
    cout << "What type of account you want"
         << " to open saving(S) or Current(C): "
         << acc_type << endl;
    balance = 8000;
    cout << "Enter How much money you want to deposit: "
         << balance << endl;
    cout << "Account Created Successfully";
}
  
// Function to deposit the account
void Bank::deposit_money()
{
    int Amount;
    Amount = 9500;
    cout << "Enter how much money"
         << " you want to deposit: "
         << Amount << endl;
    balance += Amount;
    cout << "\n Available Balance: "
         << balance;
}
  
// Function to display the account
void Bank::display_account()
{
    cout << "Name: " << name << endl
         << "Address: " << address << endl
         << "Type: " << acc_type << endl
         << "Balance: " << balance << endl
         << endl;
}
  
// Function to withdraw the account
void Bank::withdraw_money()
{
    float amount;
    amount = 3200;
    cout << "Enter how much money "
         << "you want to withdraw: "
         << amount << endl;
    balance -= amount;
    cout << "\n Available balance: "
         << balance;
}
  
// Driver code
int main()
{
    int choice;
  
    // Creating Customer Object of Bank Class
    Bank customer;
  
    cout << "\n1) Open account \n\n";
    // Calling open_account() function
    // through customer object.
    customer.open_account();
    cout << "\n------------------------"
         << "-------------------------\n";
  
    cout << "\n2) Deposit account \n\n";
    // Calling deposit_money() function
    // through customer object.
    customer.deposit_money();
    cout << "\n------------------------"
         << "-------------------------\n";
  
    cout << "\n2) Withdraw money \n\n";
    // Calling withdraw_money() function
    // through customer object.
    customer.withdraw_money();
    cout << "\n------------------------"
         << "-------------------------\n";
  
    cout << "\n4) Display Account \n\n";
    // Calling display_account() function
    // through customer object.
    customer.display_account();
    cout << "\n------------------------"
         << "-------------------------\n";
  
    return 0;
}

chevron_right


Output:

1) Open account 

Enter your full name: Aman Jhurani
Enter your address: Surat
What type of account you want to open saving(S) or Current(C): S
Enter How much money you want to deposit: 8000
Account Created Successfully
-------------------------------------------------

2) Deposit account 

Enter how much money you want to deposit: 9500

 Available Balance: 17500
-------------------------------------------------

2) Withdraw money 

Enter how much money you want to withdraw: 3200

 Available balance: 14300
-------------------------------------------------

4) Display Account 

Name: Aman Jhurani
Address: Surat
Type: S
Balance: 14300


-------------------------------------------------


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.