0% found this document useful (0 votes)
16 views

Oop Project

This C++ program defines classes for bank accounts with different banks that allow transactions like deposits, withdrawals, and balance checks. The bank class defines common attributes for customers. Derived SBI and BOI classes define bank-specific attributes and transaction functions. The main function allows the user to select a bank for account creation, displays the account number, and calls the transaction function in a loop.

Uploaded by

omchaudhari7559
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Oop Project

This C++ program defines classes for bank accounts with different banks that allow transactions like deposits, withdrawals, and balance checks. The bank class defines common attributes for customers. Derived SBI and BOI classes define bank-specific attributes and transaction functions. The main function allows the user to select a bank for account creation, displays the account number, and calls the transaction function in a loop.

Uploaded by

omchaudhari7559
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<iostream>

#include<stdlib.h>
using namespace std;
class bank
{
public:
char customerName[20];
int mobileNo,aadharNo;
bank()
{
cout<<"\nEnter name of customer : ";
cin>>customerName;
cout<<"\nEnter aadhar no. : ";
cin>>aadharNo;
cout<<"\nEnter mobile no. : ";
cin>>mobileNo;
}
virtual void transaction()=0;
};

class sbi:virtual public bank


{
public:
int sbibal=0;
int* ptr;
static int sbiacc_no;
int sbiacc=++sbiacc_no;
void transaction();
};
int sbi::sbiacc_no=0;
void sbi::transaction()
{
int ch,dAmt,wAmt;
do
{
cout<<"\nSelect type of transaction : ";
cout<<"\n1. Deposit.\n2. Withdraw.\n3. Balance Enquiry.\n4. Exit.";
cout<<"\nEnter your choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter amount to be deposited : ";
cin>>dAmt;
sbibal=sbibal+dAmt;
cout<<"Balance is : ";
cout<<sbibal;
break;
case 2:
cout<<"Enter amount to withdraw : ";
cin>>wAmt;
if(wAmt<sbibal)
{
sbibal=sbibal-wAmt;
cout<<"Balance is : ";
cout<<sbibal;
}
else
{
cout<<"Insufficient balance.";
}
break;
case 3:
cout<<"Balance is : ";
cout<<sbibal;
break;
case 4:
continue;
}
}while(ch<4);
}
class boi:virtual public bank
{
public:
int boibal=0;
int* str;
static int boiacc_no;
int boiacc=++boiacc_no;
void transaction();
};
int boi::boiacc_no=0;
void boi::transaction()
{
int ch,dAmount,wAmount;
do
{
cout<<"\nSelect type of transaction : ";
cout<<"\n1. Deposit.\n2. Withdraw.\n3. Balance Enquiry.\n4. Exit.";
cout<<"\nEnter your choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter amount to be deposited : ";
cin>>dAmount;
boibal=boibal+dAmount;
cout<<"Balance is : ";
cout<<boibal;
break;
case 2:
cout<<"Enter amount to withdraw : ";
cin>>wAmount;
if(wAmount<boibal)
{
boibal=boibal-wAmount;
cout<<"Balance is : ";
cout<<boibal;
}
else
{
cout<<"Insufficient balance.";
}
break;
case 3:
cout<<"Balance is : ";
cout<<boibal;
break;
case 4:
continue;
}
}while(ch<4);
}
/*class agent:public sbi,public boi
{
public:
int sbiloanamt=0;
int boiloanamt=0;
int choice;
void transaction()
{
cout<<"\nSelect your bank : ";
cout<<"\n1. SBI.\n2. BOI.";
if(choice==1)
{
cout<<"\nEnter amount required : ";
cin>>sbiloanamt;
sbibal=sbibal+sbiloanamt;
cout<<"\nBalance after loan : "<<sbibal;
}
else
{
cout<<"\nEnter amount required : ";
cin>>boiloanamt;
boibal=boibal+boiloanamt;
cout<<"\nBalance after loan : "<<boibal;
}
}
};*/

int main()
{
int input;
int opt;
jump:
do
{
cout<<"\nIn which bank you wish to open account?";
cout<<"\n1. SBI.\n2. BOI.";
cout<<"\nEnter your choice : ";
cin>>input;
switch(input)
{
case 1:
{
sbi s;
cout<<"\nAccount created in SBI successfully.";
cout<<"\nYour account no. is : "<<s.sbiacc;
s.transaction();
goto jump;
}
case 2:
{
boi b;
cout<<"\nAccount created in BOI successfully.";
cout<<"\nYour account no. is : "<<b.boiacc;
b.transaction();
goto jump;
}
case 3:
{
exit(0);
break;
}
}
}while(input<4);
return 0;
}

You might also like