A program to define a class to represent bank details in C++

#include<iostream>
using namespace std;
class Bank
{
private:
char Aname[20], Atype[20];
float bal;
int Ano;
public:
void getdata()
{
cout<<“enter name, acc.no and acc.type”;
cin>>Aname>>Ano>>Atype;
}
void deposit()
{
float amt;
cout<<“enter the amount to deposit”;
cin>>amt;
bal=bal+amt;
cout<<“Amount deposited”;
}
void withdraw()
{
float amt;
cout<<“enter the amount to withdraw”;
cin>>amt;
if(amt<=bal)
{
bal=bal-amt;
cout<<“Withdraw completed”;
}
else
{
cout<<“Insufficient balance”;
}
}
void displayDetail()
{
cout<<“Name=”<<Aname;
cout<<“Balance=”<<bal;
}
};
int main()
{
Bank b;
b.getdata();
b.deposit();
b.withdraw();
b.displayDetail();
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *