33% found this document useful (3 votes)
5K views

7 Managing Bank Account Using Inheritance Concept

This C++ program uses inheritance to manage bank accounts. It creates two classes - saving and current - that inherit from an account base class. The account class stores customer name, account number and type. The saving class adds deposit and balance attributes to track savings accounts. The current class adds deposit, withdrawal amount and balance for current/checking accounts. The main function demonstrates getting input, updating values, and displaying outputs for arrays of saving and current account objects.

Uploaded by

shameedp
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
33% found this document useful (3 votes)
5K views

7 Managing Bank Account Using Inheritance Concept

This C++ program uses inheritance to manage bank accounts. It creates two classes - saving and current - that inherit from an account base class. The account class stores customer name, account number and type. The saving class adds deposit and balance attributes to track savings accounts. The current class adds deposit, withdrawal amount and balance for current/checking accounts. The main function demonstrates getting input, updating values, and displaying outputs for arrays of saving and current account objects.

Uploaded by

shameedp
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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