Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // p2
- #include<iostream>
- using namespace std;
- class bank
- {
- char name[10],type[20];
- int acno;
- double bal;
- public:
- void getdata()//get info from user
- {
- cout<<"============***********++++++++++++^^^^^^^^^^^^^";
- cout<<"\n Enter the A/C no : ";
- cin>>acno;
- cout<<"\n Enter the user's name : ";
- cin>>name;
- cout<<"\n Enter the A/C's Type{saving,currant etc..} : ";
- cin>>type;
- }
- int get_acno()//get account no
- {
- return acno;
- }
- int get_bal() //get amount of ballance
- {
- return bal;
- }
- void wid_bal( double temp) // set balance amount in widthrowal
- {
- bal-=temp;
- }
- void dip_bal(double temp)// set balance amount in diposit
- {
- bal+=temp;
- }
- bank()//default constructor
- {
- bal=1000;
- }
- bank(double temp)//perameterized constructer
- {
- bal=temp;
- }
- void disp()// display the info
- {
- cout<<"\n"<<acno<<"\t"<<name<<"\t"<<type<<"\t"<<bal;
- }
- };
- int main()
- {
- bank b[10];
- bank *bt=new bank[5];
- int count=-1,ch,ano,dt[10],mt[10],j=0,k=0;
- double temp;
- do
- {
- cout<<"\n\n=====> Menu <===== \n";
- cout<<"\n 1. initialize balance default ";
- cout<<"\n 2. initialize balance manually ";
- cout<<"\n 3. deposit amount";
- cout<<"\n 4. withdraw amount after checking balance ";
- cout<<"\n 5. display";
- cout<<"\n 6. Exit";
- cout<<"\n\n Enter your choice: ";
- cin>>ch;
- switch(ch)
- {
- case 1:
- if(count>=10)
- {
- cout<<"\n You can only enter 10 records";
- }
- else
- {
- count++;
- b[count].getdata();
- b[count].disp();
- dt[j]=b[count].get_acno();
- j++;
- }
- break;
- case 2:
- if(count>=10)
- {
- cout<<"\n You can only enter 10 records";
- }
- else
- {
- count++;
- cout<<"\n Enter the balance: ";
- cin>>temp;
- bt[count]= bank(temp);
- bt[count].getdata();
- bt[count].disp();
- cout<<bt[count].get_acno();
- mt[k]=bt[count].get_acno();
- k++;
- }
- break;
- case 3:
- double add;
- cout<<"\n For deposite amount ";
- if(count==-1)
- {
- cout<<"\n Enter some records";
- }
- else
- {
- cout<<"\n Enter the A/C no: ";
- cin>>ano;
- cout<<"\n Enter the deposit amount: ";
- cin>>add;
- for(int i=0;i<=count;i++)
- {
- if(b[i].get_acno()==ano )
- {
- b[i].dip_bal(add);
- b[i].disp();
- }
- else if(bt[i].get_acno()==ano)
- {
- bt[i].dip_bal(add);
- bt[i].disp();
- }
- }
- }
- break;
- case 4:
- double sub;
- cout<<"\n For withdraw amount ";
- if(count==-1)
- {
- cout<<"\n Enter some records";
- }
- else
- {
- cout<<"\n Enter the A/C no: ";
- cin>>ano;
- cout<<"\n Enter the withdrawal amount: ";
- cin>>sub;
- for(int i=0;i<count;i++)
- {
- if(b[i].get_acno()==ano )
- {
- if(b[i].get_bal()<=1000)
- {
- cout<<"\n You can't withdraw amount because it's limit of bal 1000";
- }
- else
- {
- b[i].wid_bal(sub);
- b[i].disp();
- }
- }
- else if(bt[i].get_acno()==ano)
- {
- if(bt[i].get_bal()<=1000)
- {
- cout<<"\n You can't withdraw amount because it's limit of bal 1000";
- }
- else
- {
- bt[i].wid_bal(sub);
- bt[i].disp();
- }
- }
- }
- }
- break;
- case 5:
- for(int i=0;i<=count;i++)
- {
- for(int l=0;l<j;l++)
- {
- if(b[i].get_acno()==dt[l])
- {
- b[i].disp();
- break;
- }
- }
- }
- for(int i=0;i<=count;i++)
- {
- for(int l=0;l<k;l++)
- {
- if(bt[i].get_acno()==mt[l])
- {
- bt[i].disp();
- break;
- }
- }
- }
- break;
- }
- }while(ch>=1 && ch<=5);
- return 0;
- }
Add Comment
Please, Sign In to add comment