Define a class to represent a bank account include the following member variables.
i) Name of account.
ii) Account number.
iii) Type of account
iv) Balance
The class also has following member functions.
i) A function to assign initial value.
ii) A function to deposit an amount.
iii) A function to withdraw the amount after checking balance.
iv) A function to display the account information.
Write a menu driven program for bank system
i) Name of account.
ii) Account number.
iii) Type of account
iv) Balance
The class also has following member functions.
i) A function to assign initial value.
ii) A function to deposit an amount.
iii) A function to withdraw the amount after checking balance.
iv) A function to display the account information.
Write a menu driven program for bank system
#include<iostream.h>
#include<conio.h>
class account
{
int ac_no;
char nm[80];
float bal;
char
type[20];
public:
void
getdata()
{
cout<<"enter the account number=";
cin>>ac_no;
cout<<"enter the name=";
cin>>nm;
cout<<"enter the balance=";
cin>>bal;
cout<<"enter the type of account=";
cin>>type;
}
void
withdraw();
void
deposit();
void
display();
};
void account :: withdraw()
{
int x;
cout<<"enter the value you want to withdraw:";
cin>>x;
if(x<bal)
bal=bal-x;
else
cout<<"not enough balance:";
}
void account :: deposit()
{
int x;
cout<<"enter the amount you want to Deposit=";
cin>>x;
bal=bal+x;
}
void account :: display()
{
cout<<ac_no<<endl;
cout<<nm<<endl;
cout<<bal<<endl;
cout<<type<<endl;
}
void main()
{
clrscr();
account a;
int ch;
do
{
cout<<"MENU";
cout<<"\n1.enter new account";
cout<<"\n2.withdraw";
cout<<"\n3.deposit";
cout<<"\n4.display";
cout<<"\n5.exit";
cout<<"\nenter your choice:";
cin>>ch;
switch(ch)
{
case 1:
a.getdata();
break;
case 2:
a.withdraw();
break;
case 3:
a.deposit();
break;
case 4:
a.display();
break;
case 5:
break;
}
}
while(ch!=5);
getch();
}