Simulation of bank calling system Using linear list to simulate the bank's queuing business model 1) Suppose that the working hours of the bank are from 9 a.m. to 5 p.m 2) The time when customers arrive at the bank is generated randomly, and the customers are queued in the order of arrival. The time required for each customer to handle business can also be generated randomly, no more than 30 minutes. If the randomly generated time length is 0, it indicates that the customer leaves early and does not handle business. 3) When the program is running, input the number of bank windows, and then output the basic information of each customer's business in the bank according to the randomly generated customer data (arrival time, time required for business), including: customer arrival time, customer waiting time, what time the customer handled business in which window, and how long the business lasted. From this, we can observe the average waiting time of customers and the daily reception volume of banks when the number of windows is fixed.   In the code below store all the information of the customers in linear data structure and the number of windows so that it can display like the attached picture not otherwise

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Simulation of bank calling system

Using linear list to simulate the bank's queuing business model

1) Suppose that the working hours of the bank are from 9 a.m. to 5 p.m
2) The time when customers arrive at the bank is generated randomly, and the customers are queued in the order of arrival. The time required for each customer to handle business can also be generated randomly, no more than 30 minutes. If the randomly generated time length is 0, it indicates that the customer leaves early and does not handle business.
3) When the program is running, input the number of bank windows, and then output the basic information of each customer's business in the bank according to the randomly generated customer data (arrival time, time required for business), including: customer arrival time, customer waiting time, what time the customer handled business in which window, and how long the business lasted. From this, we can observe the average waiting time of customers and the daily reception volume of banks when the number of windows is fixed. 
 In the code below store all the information of the customers in linear data structure and the number of windows so that it can display like the attached picture not otherwise 
 

system//

#include <bits/stdc++.h>

using namespace std;

 

 

                           // this is the structure/class for customer

     struct customer{

       int ari_hr,ar_min,bt; // Arrival time-hrs:minutes, btMEANS bussiness time

 

       //operator overloading of '<' (less than) operator

       bool operator <(customer& c2){

               if(ari_hr==c2.ari_hr)ar_min<c2.ar_min;

               return ari_hr<c2.ari_hr;

       }

 

};

int main(){

       srand(time(0));

 

       int wnum;    //window numbers in bank

 

       while(1){

               cout<<"Please Enter the number of windows for the bank.\n";

               cin>>wnum;

               if(wnum<=0)break; // if wnum<=0 program will terminate

               int n=1+rand()%100;

               vector<customer> qu(n); // randomly generate all the customer arrival time and bussiness time

               for(int i=0;i<n;++i){

                       qu[i].ari_hr=9+rand()%8;

                       qu[i].ar_min=rand()%60;

                       qu[i].bt=rand()%30;

               }

               sort(qu.begin(),qu.end()); //sorting the list accprding to their arrival time

               /*

                       last[i] will store the time  at which the last customer finishes work at window i+1

                       serve_cnt[i] will count the number of customer served at window i+1

               */

               int last[wnum]={0},cust_num=0,serve_cnt[wnum]={0};

               for(int i=0;i<n;++i) {

                       if(qu[i].bt==0)continue;

                       ++cust_num;

                       int min_last=0; //store the window number which finishes earliest

                       for(int j=1;j<wnum;++j) {

                               if(last[j]<last[min_last])min_last=j;

                       }

                       ++serve_cnt[min_last];

                       int wt=last[min_last]-qu[i].ari_hr*60-qu[i].ar_min; //waiting time calulation

                       wt=max(wt,0); //waiting cant be negative

 

                       last[min_last]=(qu[i].ari_hr*60+qu[i].ar_min+wt+qu[i].bt); // updating the last of the current window

                       //printing the output into the screen

                       cout<<"number "<<cust_num<<" customer "<<qu[i].ari_hr<<":"<<qu[i].ar_min<<" arrive,";

                       cout<<" wait for  "<<wt<<"minutes, ";

                       int x=qu[i].ari_hr,y=qu[i].ar_min;

                       y+=wt;

                       x+=(y/60);

                       y%=60;

                       cout<<x<<":"<<y<<" at number "<<min_last+1<<" window  handle bussiness,last "<<qu[i].bt<<" minutes.\n";

               }

 

               cout<<"No longer accept customer bussiness, ready to leave work\n\n";

               for(int i=0;i<wnum;++i){

                       cout<<"number "<<i+1<<" window serve totally "<<serve_cnt[i]<<" customers.\n\n";

               }

       }

       return 0;

}

 

 

Win
Transcribed Image Text:Win
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Eight puzzle problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education