You are on page 1of 5

Q. Write a program to enter the details of bank account using Object Oriented Programming with C++ .

Enter the name of the accountee, account number and bank balance and display the number of accountee having more than 5000 balance .
#include<iostream.h> class bank { private: char name[20]; public: int accno; float balance; void insert(); void withdraw(); void deposite(); void display(); friend float num(bank bk[]); }; void bank::insert() { cout<<"Enter the account details:"; cin>>accno; cout<<"enter the name:"; cin>>name; cout<<"enter the balance:"; cin>>balance; } void bank::withdraw() { float n,m;

cout<<"enter the money to be withdrow:"; cin>>n; m=balance-n; if(m>500) { balance=m; cout<<"Collect your cash"; } else { cout<<"Sory can't withdrow"; } } void bank::deposite() { float a; cout<<"enter the money to be deposited:"; cin>>a; balance=balance+a; } void bank::display() { cout<<"Display the account details"; cout<<accno<<name<<balance; } float num(bank bk[]) { int i; float n=0;

for(i=0;i<3;i++) { if(bk[i].balance>5000) {n=n+1;} } return float(n); } int main() { bank b[3]; int no; int i; int c,ch; char ans,y; do { cout<<"case 1:insert"<<"\n"; cout<<"case 2:account5000"<<"\n"; cout<<"case 3:exit"<<"\n"; cout<<"enter your choice"; cin>>c; switch(c) { case 1: for(i=0;i<3;i++) {b[i].insert();}; cin>>no; for(i=0;i<3;i++) { if(b[i].accno==no)

{ cout<<"case 1:withdraw"<<"\n"; cout<<"case 2:deposite"<<"\n"; cout<<"case 3:display"<<"\n"; cout<<"case 4:exit"<<"\n"; cout<<"enter your choice:"; cin>>c; switch(ch) { case 1: b[i].withdraw(); break; case 2: b[i].deposite(); break; case 3: b[i].display(); break; case 4: return 0; default: cout<<"invalid choice"; break; } } else{cout<<"Invalid account number"<<"\n"; } break; case 2: cout<<"Nos of accountee having balance more than 5000"<<num(b);

break; case 3: return 0; default: cout<<"invalid choice"; break; }}cout<<"Display manu 1(y/n):"; cin>>ans; }while(ans=y); return 0; }