28. In a bank, different customers having saving account. Some customers may have taken a loan from the bank. So bank always maintains information about bank depositors and borrowers. Design a Baseclass Customer (name, phone-number).Derive a class Depositor(accno, balance)from Customer. Again derive a class Borrower (loan-no, loan-amt) from Depositor.Write necessary member functions to read and display the details of ‘n’ customers.


#include<iostream.h>
#include<conio.h>
class customer
{
char name[20];
char pno[10];
public:
void get()
{
cout<<“\nEnter the Name & Phone no.\n”;
cin>>name>>pno;
}
void disp_c()
{
cout<<name<<“\t”<<pno<<“\t\t”;
}
};
class depositor:public customer
{

int accno;
float bal;
public:
void get_d()
{
cout<<“\nEnter the A/c no. & Balance: \n”;
cin>>accno>>bal;
}
void disp_d()
{
cout<<“\t”<<accno<<“\t”<<“\t\t”<<bal<<endl;
}
};
class borrower:public depositor
{
int lno;
float lamt;
public:
void get_b()
{
get();
get_d();
cout<<“\nEnter the loan no. & loan amount: \n”;
cin>>lno>>lamt;
}
void display()
{
disp_c();
disp_d();
cout<<“\t”<<lno<<“\t\t”<<lamt<<endl;
}
};
void main()
{
int n,i;
borrower b[10];
clrscr();
cout<<“\nHow many customer: \n”;
cin>>n;
for(i=0;i<n;i++)
{
b[i].get_b();
}
cout<<“\nThe Detail’s of Customer’s: \n”;
cout<<“Name\tPNo.\tA/C no.\t\tBalance\t\tLoan no.\tLoan amt\n”;
cout<<“============================================\n”;
for(i=0;i<n;i++)
{
b[i].display();
}
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