Advertisement
AshfaqFardin

Basic Banking

Jul 7th, 2021
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct bankAccountUser
  6. {
  7.     string name;
  8.     string accountNumber;
  9.     int currentBalance;
  10.  
  11.     void withdrawMoney(int amount)
  12.     {
  13.         if(currentBalance > amount){
  14.             currentBalance -= amount;    
  15.         }
  16.         else
  17.             cout << "Not enough balance\n";
  18.     }
  19.    
  20.     void depositeMoney(int amount)
  21.     {
  22.         currentBalance += amount;
  23.     }
  24.    
  25.     void balanceCheck()
  26.     {
  27.         cout << "Current Balance: " << currentBalance << endl;
  28.     }
  29. };
  30.  
  31.  
  32. int main()
  33. {
  34.     bankAccountUser *user = new bankAccountUser[10];
  35.    
  36.     user[0].name = "Ashfaq";
  37.     user[0].accountNumber = "1234546546";
  38.     user[0].currentBalance = 1000;
  39.     // a.name = "Ashfaq";
  40.     // a.accountNumber = "947329843";
  41.     // a.currentBalance = 1000;
  42.    
  43.     user[0].withdrawMoney(10);
  44.     user[0].depositeMoney(20);
  45.     user[0].balanceCheck();
  46.     //a.withdrawMoney(10);
  47.     //a.depositeMoney(20);
  48.     //a.balanceCheck();
  49.     delete []user;
  50.    
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement