Site icon T4Tutorials.com

C++ bank account program

Bank account program in C++ using the classes, objects, data members, and member functions.

Data members of the class
Name of the depositor.
Account number of the account holder.
Type of bank account
Total Balance amount in the bank account of the account holder.

Member functions of the class
To assign initial values.
To deposit an amount in the account.
To withdraw an amount after checking the balance from the bank account
To display the name and balance of the account holder.

#include<iostream>
#include<stdio.h>
#include<string.h>

using namespace std;

class T4Tutorials
{
        int acno;
        char AccountHolderName[100], Account_Type[100];
        float bal;  
   public:
        T4Tutorials(int acc_no, char *name, char *acc_type, float Balance)  //Parameterized Constructor
        {
                acno=acc_no;
                strcpy(AccountHolderName, name);
                strcpy(Account_Type, acc_type);
                bal=Balance;
        }
        void deposit();
        void withdraw();
        void Show();
};
void T4Tutorials::deposit()   //depositing an amount
{
        int DepositAmmount1;
        cout<<" Enter Deposit Amount = "<<endl;
        cin>>DepositAmmount1;
        bal+=DepositAmmount1;
}
void T4Tutorials::withdraw()  //withdrawing an amount
{
        int WithdrawAmmount1;
        cout<<" Enter Withdraw Amount = "<<endl;
        cin>>WithdrawAmmount1;
        if(WithdrawAmmount1>bal)
                cout<<" Cannot Withdraw Amount"<<endl;
        bal-=WithdrawAmmount1;
}
void T4Tutorials::Show()  //Showing the details
{
        cout<<" *************"<<endl;
        cout<<" Accout No. : "<<acno;
        cout<<" Name : "<<AccountHolderName;
        cout<<" Account Type : "<<Account_Type;
        cout<<" Balance : "<<bal;  
}
int main()
{
        int acc_no;
        char name[100], acc_type[100];
        float Balance;
        cout<<" Enter Details: "<<endl;
        cout<<"***********"<<endl;
        cout<<" Accout No. "<<endl;
        cin>>acc_no;
        cout<<" Name : "<<endl;
        cin>>name;
        cout<<" Account Type : "<<endl;
        cin>>acc_type;
        cout<<" Balance : "<<endl;
        cin>>Balance;
  
        T4Tutorials b1(acc_no, name, acc_type, Balance);  //object is created
        b1.deposit(); //
        b1.withdraw(); // calling member functions
        b1.Show(); //
        return 0;
}

Output

Bank Management System Project in C++

Covered

Exit mobile version