Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this project, you will simulate the reception of a bank. You will have custo

ID: 3919904 • Letter: F

Question

For this project, you will simulate the reception of a bank. You will have customers requesting transactions (open account, deposit money, close account, withdraw money).

You are required to simulate per the following parameters and rules:

Customers coming at random times

Each customer will require random amount of service time

You may have 1-3 tellers based on the # of customers

Once you have more than 4 customers waiting you need to get the 2nd teller

Once you have more than 8 customers waiting you need to get the 3rd teller

Once the line size gets smaller, you should remove the tellers in opposite order of their addition (the last one joining should be the first one leaving)

The reception operates from 10:00 AM until 1:00 PM

At the end of the day, you need to run the following reports:A list of customers coming along with the type of transactions they requested. This report should be sorted by:

Last name of the customer

Amount of money involved

Time of arrival

Average waiting time per customers

Average number of customers waiting

Explanation / Answer

SOLUTION:

According to the given data the below C++ code follows ;

CODE:

#include <iostream>

#include <queue>

#include <list>

#include <cstdlib>

#include <ctime>

using namespace std;

const int slice = 3;

class Customer {

struct cust

{

int depmoney,arivaltime, avgwttime, trantype;

string name

}cust[20];

public:

Customer() {

depmoney=arivaltime= avgwttime =0 ;

name=null;

}

  

};

class Teller {

queue<Customer>& customers;

Customer current;

int ttime; // Time left in slice

bool busy; // Is teller serving a customer?

public:

Teller(queue<Customer>& cq)

: customers(cq), ttime(0), busy(false) {}

Teller& operator=(const Teller& rv) {

customers = rv.customers;

current = rv.current;

ttime = rv.ttime;

busy = rv.busy;

return *this;

}

bool isBusy() { return busy; }

void run(bool recursion = false) {

if(!recursion)

ttime = slice;

int servtime = current.getTime();

if(servtime > ttime) {

servtime -= ttime;

current.setTime(servtime);

busy = true; // Still working on current

return;

}

if(servtime < ttime) {

ttime -= servtime;

if(!customers.empty()) {

current = customers.front();

customers.pop(); // Remove it

busy = true;

run(true); // Recurse

}

return;

}

if(servtime == ttime) {

// Done with current, set to empty:

current = Customer(0);

busy = false;

return; // No more time in this slice

}

}

};

// Inherit to access protected implementation:

class CustomerQ : public queue<Customer> {

public:

friend ostream&

operator<<(ostream& os, const CustomerQ& cd) {

copy(cd.c.begin(), cd.c.end(),

ostream_iterator<Customer>(os, ""));

return os;

}

};

Now pull it all together, and run it for a while

void main() {

CustomerQ customers;

list<Teller> tellers;

typedef list<Teller>::iterator TellIt;

tellers.push_back(Teller(customers));

srand(time(0)); // Seed random number generator

  

while(q=0;q < 20;q++) {

// Add a random number of customers to the

// queue, with random service times:

for(int i = 0; i < rand() % 5; i++)

customers.push(Customer(rand() % 15 + 1));

cout<<" MAIN MENU";

cout<<" 01. NEW ACCOUNT";

cout<<" 02. DEPOSIT AMOUNT";

cout<<" 03. WITHDRAW AMOUNT";

cout<<" 04. CLOSE AN ACCOUNT";

cout<<" Select Your Option (1-4) ";

cin>>trantype;

cout << "enter cust name";

cin>>cust[q].name

cout << "enter depmoney, if you are type of close account then enter 0 ;

cin>> cust[q].depmoney;

cout << "enter arivaltime (between 10:00 AM to 1:00 PM)";

cin>> cust[q].arivaltime

cout << "enter avgwttime";   

cin>> cust[q].avgwttime

cout << '{' << tellers.size() << '}'

<< customers << endl;

// Have the tellers service the queue:

for(TellIt it = tellers.begin();

it != tellers.end(); it++)

(*it).run();

cout << '{' << tellers.size() << '}'

<< customers << endl;

// If line is too long, add another teller:

if(customers.size() >4)

tellers.push_back(Teller(customers));

if(customers.size() >8)

tellers.push_back(Teller(customers));

// If line is short enough, remove a teller:

if(customers.size()<8)

{

tellers.erase(3);

break; // Out of for loop

}

if(customers.size()<4)

{

tellers.erase(2);

break; // Out of for loop

}

for(int i=0;i<20;i++)

{

cout << " Name: " << cust[i].name << endl;

cout << "Transaction type " << cust[i]. trantype << endl;

cout << " Deposit money " << cust[i]. depmoney << endl;

cout << "Arivaltime, avgwttime " << cust[i]. arivaltime << endl;

cout << "Avgwttime " << cust[i]. avgwttime << endl;

}

}

}

Hence our required code is obtained

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote