AshfaqFardin

Bank Check In

Jul 9th, 2021 (edited)
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <unistd.h>
  3. using namespace std;
  4. void enqueue();
  5. void dequeue();
  6. bool isEmpty();
  7. bool isFull();
  8. void end();
  9.  
  10. int numberOfPeople = 10;
  11. string accountOwnerName[10];
  12. int front = 0;
  13. int rear = -1;
  14. int count = 0;
  15.  
  16.  
  17. bool isEmpty(){
  18.     if(front > rear){
  19.         return true;
  20.     }
  21. }
  22.  
  23. bool isFull(){
  24.     if(rear == numberOfPeople - 1) return true;
  25. }
  26.  
  27. void dequeue(){
  28.     for(int i = 0; i < numberOfPeople; i++){
  29.         cout.flush();
  30.         //sleep(120);
  31.         sleep(2); // 2 seconds taken instead of 120 seconds
  32.         cout << accountOwnerName[i] << " LEFT" << endl;
  33.         rear--;
  34.     }
  35. }
  36.  
  37. void enqueue(){
  38.     if(isEmpty){
  39.         cout << "ENTER TEN PEOPLE NAME:\n";
  40.         for(int i = 0; i < numberOfPeople; i++){
  41.             cin >> accountOwnerName[i];
  42.             rear++;
  43.         }
  44.     }
  45.     if(isFull){
  46.         cout << "WAIT OUTSIDE PLEASE\n";
  47.         dequeue();
  48.     }
  49. }
  50.  
  51.  
  52. void end(){
  53.     cout << "BANK IS CLOSED FOR THE DAY\n";
  54. }
  55.  
  56. int main(){
  57.     int turns = 3;
  58.     for(int i = 0; i < turns; i++){
  59.         enqueue();
  60.         count++;
  61.     }
  62.     if(count == 3){
  63.         end();
  64.     }
  65.     return 0;
  66. }
  67.  
Add Comment
Please, Sign In to add comment