0% found this document useful (0 votes)
183 views4 pages

C++ Bank Management Program

This C++ program implements a basic banking system using classes and objects. The Bank class contains data members like account number, name, balance and address of a customer. Member functions setcustomerinfo() and showcustomerinfo() are used to input and display customer details. Deposit() and withdraw() functions update the balance. The main() function contains a menu to create accounts, deposit/withdraw amounts and display information by searching the account number. Customer objects are created in an array to represent multiple accounts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views4 pages

C++ Bank Management Program

This C++ program implements a basic banking system using classes and objects. The Bank class contains data members like account number, name, balance and address of a customer. Member functions setcustomerinfo() and showcustomerinfo() are used to input and display customer details. Deposit() and withdraw() functions update the balance. The main() function contains a menu to create accounts, deposit/withdraw amounts and display information by searching the account number. Customer objects are created in an array to represent multiple accounts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

/*

--------------- Assignment – 2 --------------


Date :13/Sep/2020
Day: Sunday
Name: M. Vamshi
Roll no. : 19D41A05E2

Aim:
C++ program for Banking System using Class and Objects

*/

#include<iostream>
using namespace std;
class Bank
{
private:
int accno;
string name;
float balance;
string address;

public:
Bank() // constructor
{
accno=0000000;
balance=0.0;

void setcustomerinfo();

void showcustomerinfo();

void deposit();

void withdraw();

int search (int a);


};

void Bank::setcustomerinfo()
{
cout<<"\n Enter Account Number : ";

cin>>accno;
cout<<"\n Enter Name : ";
cin>>name;
cout<<"\n Enter Balance : ";
cin>>balance;
cout<<"\n Enter adress : ";
cin>>address;

void Bank::showcustomerinfo()
{
cout<<"\n\n--------------------- Account detials --------------"<<endl;
cout<<"\n Account Number : "<<accno<<endl;
cout<<"\n Name : "<<name<<endl;
cout<<"\n Balance : "<<balance<<endl;
cout<<"\n Address : "<<address<<endl;

void Bank::deposit()
{

int amt;
cout<<"\n\n Enter how much amout do you want to deposit : ";
cin>>amt;
balance=balance+amt;
cout<<"\n\n*********** Deposit successful ***********"<<endl;

void Bank::withdraw()
{

int amt;
cout<<"\n\n Enter how much the Amount do you want to withdraw : ";
cin>>amt;
if (amt<=balance)
{
balance=balance-amt;
cout<<"*********** Withdrawal Successful ***********"<<endl;
}

else
{
cout<<"*********** Insufficient Balance !!! ***********"<<endl;
}
}
int Bank::search(int a)
{

if (accno == a)
{
showcustomerinfo();
return 1;
}

return 0;
}

int main()
{
Bank Customer[3];
int found = 0, a, ch, i;
do {
cout << "\n _____________ × Main Menu × _____________"<<endl;
cout << "\n\n 1: Create Account \n\n 2: Cash Deposit\n\n 3:
Cash Withdrawal \n\n 4: Display Account Info\n\n 5: Exit\n" << endl;
cout << " Enter your choice [ 1 / 2 / 3 / 4 / 5 ]: ";
cin >> ch;
switch (ch) {
case 1: // account creation
for (i = 0; i <= 2; i++)
{
int s=i;

cout<<"\n\n-------------------------------------------------------------------"<<en
dl;
cout <<"\n\n Enter details of customer #"<<s+1<<"\n"<<endl;
Customer[i].setcustomerinfo();
}
break;
case 2: // deposit operation
cout << "\n\n Enter Account Number To Deposit Amount : ";
cin >> a;
for (i = 0; i <= 2; i++)
{
found = Customer[i].search(a);
if (found)
{
Customer[i].deposit();
break;
}
}
if (!found)
cout << "\n\n---No record found !!! ---" << endl;
break;

case 3: // withdraw operation


cout << "\n\nEnter Account Number To Withdraw Amount : ";
cin >> a;
for (i = 0; i <= 2; i++)
{
found = Customer[i].search(a);
if (found)
{
Customer[i].withdraw();
break;
}
}
if (!found)
cout << "\n\n---No record found !!! ---" << endl;
break;
case 4 : //display customer info
cout<<"\n Enter Customer Account Number : ";
cin>>a;
for (i = 0; i <= 2; i++)
{
found = Customer[i].search(a);
if (found)
break;
}

if(!found)
cout << "\n\n---No record found !!! ---" << endl;
break;
case 5: // exit
cout << " \n\n ×××× Thanks for Banking. Have a nice day :) ×××× \n" <<
endl;
break;
default:
cout << "-------- Invalid Option --------- " << endl;
}
} while (ch!=5);
return 0;

You might also like