#include<iostream.h>
#include<conio.h>
class Customer
{
protected:
char name[20];
char phone_no[10];
int flag;
public:
void getdata()
{
cout<<endl<<"Enter Name: ";
cin>>name;
cout<<endl<<"Enter Phone No.: ";
cin>>phone_no;
}
void display()
{
cout<<"Name: "<<name<<"\t Phone No.: "<<phone_no;
}
void setflag(int n)
{
flag=n;
}
};//End of Customer class
class Depositor:public Customer
{
protected:
int acc_no;
float balance;
public:
void getdata()
{
cout<<endl<<"Enter Account No.: ";
cin>>acc_no;
cout<<endl<<"Enter Balance: ";
cin>>balance;
}
void display()
{
cout<<" Account No.: "<<acc_no<<" Balance: Rs."<<balance<<"/-";
}
};//End of Depositor class
class Borrower:public Depositor
{
int loan_no;
float loan_amt;
public:
void getdata()
{
cout<<endl<<"Enter Loan No.: ";
cin>>loan_no;
cout<<endl<<"Enter Loan Amount: ";
cin>>loan_amt;
}
void display_loan()
{
if(flag==1)
{
Customer::display();
Depositor::display();
cout<<" Loan No.: "<<loan_no<<" Loan Amount: Rs."<<loan_amt<<"/-";
}
}
void display_no_loan()
{
if(flag==0)
{
Customer::display();
Depositor::display();
cout<<"\tLoan: Nill";
}
}
void display_both()
{
if(flag==2)
{
Customer::display();
Depositor::display();
Borrower::display();
}
}
}b[100];//End of Borrower class
int main()
{
int n,choice;
clrscr();
cout<<endl<<"Enter number of customers: ";
cin>>n;
cout<<endl<<endl<<"Enter details of customer: ";
for(int i=0;i<n;i++)
{
cout<<endl<<"New Customer:";
cout<<endl<<"1.Depositor"<<endl<<"2.Borrower"<<endl<<"3.Depositor and Borrower";
cout<<"Enter type: ";
cin>>choice;
switch(choice)
{
case 1:
b[i].Customer::getdata();
b[i].Depositor::getdata();
b[i].setflag(1);
break;
case 2:
b[i].Customer::getdata();
b[i].Borrower::getdata();
b[i].setflag(0);
break;
case 3:
b[i].Customer::getdata();
b[i].Depositor::getdata();
b[i].Borrower::getdata();
b[i].setflag(2);
default:
cout<<endl<<"Wrong Choice!";
}
}
cout<<endl<<endl<<"Customers having only Saving A/C(only Depositors): ";
cout<<endl<<"___________________________________________________"<<endl<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<endl;
b[i].display_no_loan();
}
cout<<endl<<endl<<"Customers having only Loan A/C(only Borrowers): ";
cout<<endl<<"___________________________________________________"<<endl<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<endl;
b[i].display_loan();
}
cout<<endl<<"Customers having both Saving A/C and Loan A/C(both Depositors and Borrowers): ";
cout<<endl<<endl<<"____________________________________________________________________________________"<<endl<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<endl;
b[i].display_both();
}
getch();
return 0;
}
Post a Comment