Aniket_Goku

p2

Nov 3rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.92 KB | None | 0 0
  1. //  p2
  2. #include<iostream>
  3. using namespace std;
  4. class bank
  5. {
  6.     char name[10],type[20];
  7.     int acno;
  8.     double bal;
  9.     public:
  10.         void getdata()//get info from user
  11.         {
  12.             cout<<"============***********++++++++++++^^^^^^^^^^^^^";
  13.             cout<<"\n Enter the A/C no : ";
  14.             cin>>acno;
  15.             cout<<"\n Enter the user's name : ";
  16.             cin>>name;
  17.             cout<<"\n Enter the A/C's Type{saving,currant etc..} : ";
  18.             cin>>type;
  19.         }
  20.         int get_acno()//get account no
  21.         {
  22.             return acno;
  23.         }
  24.         int get_bal() //get amount of ballance
  25.         {
  26.             return bal;
  27.         }
  28.         void wid_bal( double temp) // set balance amount in widthrowal
  29.         {
  30.             bal-=temp;
  31.            
  32.         }
  33.         void dip_bal(double temp)// set balance amount in diposit
  34.         {
  35.             bal+=temp;
  36.         }
  37.    
  38.         bank()//default constructor
  39.         {
  40.        
  41.             bal=1000;
  42.         }
  43.         bank(double temp)//perameterized constructer
  44.         {
  45.            
  46.             bal=temp;
  47.         }
  48.         void disp()// display the info
  49.         {
  50.             cout<<"\n"<<acno<<"\t"<<name<<"\t"<<type<<"\t"<<bal;
  51.         }
  52.    
  53. };
  54. int main()
  55. {  
  56.     bank b[10];
  57.     bank *bt=new bank[5];
  58.     int count=-1,ch,ano,dt[10],mt[10],j=0,k=0;
  59.     double temp;
  60.     do
  61.     {
  62.  
  63.         cout<<"\n\n=====> Menu <===== \n";
  64.         cout<<"\n 1. initialize balance default ";
  65.         cout<<"\n 2. initialize balance manually ";
  66.         cout<<"\n 3. deposit amount";
  67.         cout<<"\n 4. withdraw amount after checking balance ";
  68.         cout<<"\n 5. display";
  69.         cout<<"\n 6. Exit";
  70.         cout<<"\n\n Enter your choice: ";
  71.         cin>>ch;
  72.         switch(ch)
  73.         {
  74.             case 1:
  75.                 if(count>=10)
  76.                 {
  77.                     cout<<"\n You can only enter 10 records";
  78.                    
  79.                 }
  80.                 else
  81.                 {
  82.                    
  83.                     count++;
  84.                     b[count].getdata();
  85.                    
  86.                     b[count].disp();
  87.                     dt[j]=b[count].get_acno();
  88.                     j++;
  89.                 }
  90.             break;
  91.             case 2:
  92.                 if(count>=10)
  93.                 {
  94.                     cout<<"\n You can only enter 10 records";
  95.                 }
  96.                 else
  97.                 {
  98.                    
  99.                     count++;
  100.                     cout<<"\n Enter the balance: ";
  101.                     cin>>temp;
  102.                     bt[count]= bank(temp);
  103.                     bt[count].getdata();
  104.                     bt[count].disp();
  105.                     cout<<bt[count].get_acno();
  106.                     mt[k]=bt[count].get_acno();
  107.                     k++;
  108.                 }
  109.             break;
  110.            
  111.             case 3:
  112.                
  113.                 double add;
  114.                 cout<<"\n For deposite amount ";
  115.                 if(count==-1)
  116.                 {
  117.                     cout<<"\n Enter some records";
  118.                 }
  119.                 else
  120.                 {
  121.                        
  122.                     cout<<"\n Enter the A/C no: ";
  123.                     cin>>ano;
  124.                    
  125.                     cout<<"\n Enter the deposit amount: ";
  126.                     cin>>add;
  127.                     for(int i=0;i<=count;i++)
  128.                     {
  129.                         if(b[i].get_acno()==ano )
  130.                         {
  131.                             b[i].dip_bal(add);
  132.                             b[i].disp();
  133.                         }
  134.                         else if(bt[i].get_acno()==ano)
  135.                         {
  136.                             bt[i].dip_bal(add);
  137.                             bt[i].disp();
  138.                         }
  139.                     }
  140.                    
  141.                    
  142.                 }  
  143.             break;
  144.            
  145.             case 4:
  146.                 double sub;
  147.                 cout<<"\n For withdraw amount ";
  148.                 if(count==-1)
  149.                 {
  150.                     cout<<"\n Enter some records"; 
  151.                 }
  152.                 else
  153.                 {
  154.                    
  155.                
  156.                     cout<<"\n Enter the A/C no: ";
  157.                     cin>>ano;
  158.                     cout<<"\n Enter the withdrawal amount: ";
  159.                     cin>>sub;
  160.                    
  161.                     for(int i=0;i<count;i++)
  162.                     {
  163.                         if(b[i].get_acno()==ano )
  164.                         {
  165.                             if(b[i].get_bal()<=1000)
  166.                             {
  167.                                 cout<<"\n You can't withdraw  amount because it's limit of bal 1000";
  168.                             }
  169.                             else
  170.                             {
  171.                                 b[i].wid_bal(sub);             
  172.                                 b[i].disp();
  173.                             }
  174.                         }
  175.                         else if(bt[i].get_acno()==ano)
  176.                         {
  177.                             if(bt[i].get_bal()<=1000)
  178.                             {
  179.                                 cout<<"\n You can't withdraw  amount because it's limit of bal 1000";
  180.                             }
  181.                             else
  182.                             {
  183.                                 bt[i].wid_bal(sub);            
  184.                                 bt[i].disp();
  185.                             }
  186.                         }          
  187.                     }
  188.                 }
  189.             break;
  190.             case 5:
  191.                 for(int i=0;i<=count;i++)  
  192.                 {
  193.                     for(int l=0;l<j;l++)
  194.                     {
  195.                        
  196.                         if(b[i].get_acno()==dt[l])
  197.                         {
  198.                             b[i].disp();
  199.                             break;
  200.                         }
  201.                     }
  202.                 }
  203.                 for(int i=0;i<=count;i++)  
  204.                 {
  205.                     for(int l=0;l<k;l++)
  206.                     {
  207.                        
  208.                         if(bt[i].get_acno()==mt[l])
  209.                         {
  210.                             bt[i].disp();
  211.                             break;
  212.                         }
  213.                     }
  214.                    
  215.                
  216.                 }
  217.             break;
  218.         }
  219.        
  220.     }while(ch>=1 && ch<=5);
  221.    
  222.     return 0;
  223. }
  224.  
Add Comment
Please, Sign In to add comment