varungurnaney

HSC: Bank

Sep 17th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  
  4. class account
  5. {       public:
  6.     int no;
  7.     int bal;
  8.     public:
  9.     account()
  10.     {bal=5000;}
  11.     void deposit(int val);
  12.     int withdraw(int val);
  13.     void checkbal();
  14.     void giveoptions();
  15.  
  16. };
  17. void account:: deposit(int val)
  18.     {
  19.      bal+=val;
  20.     }
  21.  
  22. int account::  withdraw(int val)
  23.     {
  24.      bal-=val;
  25.      return val;
  26.     }
  27.  
  28. void account:: checkbal()
  29.     {
  30.     cout<<"balance is"<<bal<<endl;
  31.     }
  32.  
  33.  
  34. void account :: giveoptions()
  35. {
  36.  int ch=0,val;
  37.  while(ch!=4)
  38.  {
  39.  cout<<"MENU \n 1.Deposist 2.Withdraw \n 3.Checkbal\n4.Exit"<<endl;
  40.  cin>>ch;
  41.  
  42.  switch(ch)
  43.  {
  44.  case 1:cout<<"\nenter value to deposit\n";
  45.     cin>>val;
  46.     deposit(val);
  47.     checkbal();
  48.     break;
  49.  
  50.  case 2:cout<<"\nEnter value to withdraw\n";
  51.     cin>>val;
  52.     if(bal<=val+5000)
  53.     {
  54.     cout<<"\nCannot withdraw. You're poor\n";
  55.     break;
  56.     }
  57.     cout<<"\nCollect your money"<<withdraw(val);
  58.     checkbal();
  59.     break;
  60.  
  61.  case 3: checkbal();
  62.     break;
  63.  case 4: break;
  64.  default: break;
  65.  }
  66.  }
  67. }
  68.  
  69. void main()
  70. {
  71. clrscr();
  72. int n;
  73. account a1,a2,a3;
  74. a1.no=123;
  75. a2.no=456;
  76. a3.no=789;
  77. for(int i=0;i<3;i++)
  78. {
  79. cout<<"Enter account number"<<endl;
  80. cin>>n;
  81. if(n==123)
  82. {a1.giveoptions();}
  83. if(n==456)
  84. {a2.giveoptions();}
  85. if(n==789)
  86. {a3.giveoptions();}
  87.  
  88. }
  89. getch();
  90. }
Add Comment
Please, Sign In to add comment