7 Managing Bank Account Using Inheritance Concept

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

MANAGING BANK ACCOUNT USING INHERITANCE CONCEPT

Program:
#include<iostream.h>
#include<conio.h>
class account
{
protected:
char cust_name[10];
int acc_no;
char acc_type[10];
public:
void getdata();
void putdata();
};
void account::getdata()
{
cout<<"Enter the customer name:";
cin>>cust_name;
cout<<"Enter the account Number:";
cin>>acc_no;
cout<<"Enter the account type:";
cin>>acc_type;
}
void account :: putdata()
{
cout<<"Customer Name:"<<cust_name<<"\n";
cout<<"Account Number:"<<acc_no<<"\n";
cout<<"Account type:"<<acc_type<<"\n";
}
class saving : public account
{
float deposit;
float balance;
public:
saving()
{
deposit=500;
balance=deposit;
}
void s_update();
void s_display();
};
void saving::s_update()
{
putdata();
cout<<"Enter the deposit amount:";
cin>>deposit;
balance=balance+deposit;
}
void saving::s_display()
{
putdata();
cout<<"Balance:"<<balance<<"\n";
}
class current : public account
{
float deposit;
float wd_amt;
float balance;
public:
current()
{
deposit=500;
balance=deposit;
}
void c_update();
void c_display();
};
void current::c_update()
{
cout<<"Enter the deposit amount:";
cin>>deposit;
cout<<"Enter the withdrawal amount:";
cin>>wd_amt;
balance=balance+(deposit-wd_amt);
}
void current::c_display()
{
putdata();
cout<<"Balance:"<<balance<<"\n";
}
void main()
{
saving s[3];
current c[3];
int i;
cout<<"Enter the customer details for saving account";
for(i=0;i<3;i++)
{
s[i].getdata();
clrscr();
}
cout<<"Enter the customer detials for the current account:";
for(i=0;i<3;i++)
{
c[i].getdata();
clrscr();
}
cout<<"Update the values for saving account:";
for(i=0;i<3;i++)
{
s[i].putdata();
s[i].s_update();
clrscr();
}
cout<<"Update the values for current account:";
for(i=0;i<3;i++)
{
c[i].putdata();
c[i].c_update();
clrscr();
}
cout<<"Customer details for saving account:";
for(i=0;i<3;i++)
{
s[i].s_display();
getch();
clrscr();
}
cout<<"Customer details for current account:";
for(i=0;i<3;i++)
{
c[i].c_display();
getch();
clrscr();
}
}

You might also like