6. Define a class to represent a bank account which includes following members : Data members – 1)Name 2)Account number 3)Type of account 4)Bal. amt Member functions – a.To assign initial value b.To deposit an account c.To withdraw an account d.To display name, account number & balance.


#include<iostream.h>
#include<conio.h>
#include<string.h>
class bank
{
char name[20];
int ano;
char atype[20];
float bal;
public:
void get(int no,char *n,char *t,float b)
{
strcpy(name,n);
ano=no;
strcpy(atype,t);
bal=b;
}
float deposit()
{
float amt;
cout<<“\nEnter amount: “;
cin>>amt;
bal=bal+amt;
return bal;
}
float withdrw()
{
float amt;
cout<<“\nHow many Rupees withdraw: “;
cin>>amt;
bal=bal-amt;
return bal;
}
void disp()
{
cout<<“\n\nAccount number: “<<ano;
cout<<“\n\nName: “<<name;
cout<<“\n\nAccount type: “<<atype;
cout<<“\n\nDeposit Amount: “<<deposit();
cout<<“\n\nAfter Withdraw Amount balnace: “<<withdrw();
}
};
void main()
{
int n;
char nm[20],t[20];
float a;
bank bk;
clrscr();
cout<<“\nEnter Account no.: “; cin>>n;
cout<<“\nEnter Name: “; cin>>nm;
cout<<“\nEnter account type: “; cin>>t;
cout<<“\nEnter balance amount: “;cin>>a;
bk.get(n,nm,t,a);
bk.disp();
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s