Skip to content

luisiestrada/BankSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BankSimulator

Introduction

This program simulates a bank with multiple tellers and customers. A bank service area consists of several tellers and a customer queue. In each time unit, at most one new customer arrives at the queue. If the queue is too long, the customer leaves without completing their transaction; otherwise, the customer gets into the queue. If all tellers are busy, customers in the queue must wait for a teller. If a teller is free and customers are waiting, the first customer in the queue advances to the teller's counter and begins their transaction. When a customer is done, they depart and the teller becomes free. The simulation is run through many units of time. At the end of each time unit, the program prints out a snapshot of the queues, customers, and tellers. The program ends with printing out statistics of the simulation.

Assumptions and Requirements

Assumptions

  • At most one customer arrives per time unit
  • All numbers are positive integer numbers (>=0), except average values should be displayed to two decimal places
  • No time lost in between the following events:
    • a customer arriving and entering the queue
    • a customer arriving and leaving without banking
    • a customer completing their transaction and departing
    • a customer leaving the queue, advancing to a teller and beginning their transaction

The limits of simulation parameters

  • Maximum number of tellers 10
  • Maximum simulation length 10000
  • Maximum transaction time 500
  • Maximum customer queue limit 50
  • Probability of a new customer 1% - 100%

Input parameters and customer (random/file) data

The following data are read at the beginning of the simulation:

  • int numTellers; // number of tellers
  • int simulationTime; // time to run simulation
  • int customerQLimit; // customer queue limit
  • int chancesOfArrival; // probability of a new customer (1 - 100)
  • int maxTransactionTime; // maximum transaction time per customer
  • int dataSource; // data source: from file or random
Sample input layout:
$ java simulator.BankSimulator

	***  Get Simulation Parameters  ***

Enter simulation time (max is 10000): 10
Enter maximum transaction time of customers (max is 500): 5
Enter chances (0% < & <= 100%) of new customer: 75
Enter the number of tellers (max is 10): 3
Enter customer queue limit (max is 50): 2
Enter 1/0 to get data from file/Random: 1
Reading data from file. Enter file name: DataFile

In each time unit of the simulation, the program needs two positive integers to compute: (i) boolean anyNewArrival and (ii) int transactionTime.

A user has two options (1 or 0) to specify the source of those numbers:

For user input 1, numbers are read from a file. A filename should be provided at the beginning of the simulation. Each line in a datafile should contain two positive numbers (> 0). A datafile should contain sufficient data for simulationTime up to 500 units, i.e., at least 500 lines. In each time unit, anyNewArrival & transactionTime are computed as follows:

read data1 and data2 from the file;
anyNewArrival = (((data1 % 100) + 1) <= chancesOfArrival);
transactionTime = (data2 % maxTransactionTime) + 1;

For user input 0, numbers are generated by method nextInt() in a Random object, dataRandom, which is constructed at the beginning of the simulation. In each time unit, anyNewArrival & transactionTime are computed as follows:

anyNewArrival = ((dataRandom.nextInt(100) + 1) <= chancesOfArrival);
transactionTime = dataRandom.nextInt(maxTransactionTime) + 1;

Output information

Sample output layout:

	*** Start Simulation ***

---------------------------------------------------------------
Time  : 1
Queue : 0/2
	Customer #1 arrives with transaction time 5 unit(s).
	Customer #1 waits in the customer queue.
	Customer #1 gets teller #1 for 5 unit(s).
---------------------------------------------------------------
Time  : 2
Queue : 0/2
	Customer #2 arrives with transaction time 2 unit(s).
	Customer #2 waits in the customer queue.
	Customer #2 gets teller #2 for 2 unit(s).
---------------------------------------------------------------
Time  : 3
Queue : 0/2
	Customer #3 arrives with transaction time 5 unit(s).
	Customer #3 waits in the customer queue.
	Customer #3 gets teller #3 for 5 unit(s).
---------------------------------------------------------------
Time  : 4
Queue : 0/2
	No new customer!
	Customer #2 is done.
	Teller #2 is free.
---------------------------------------------------------------
Time  : 5
Queue : 0/2
	Customer #4 arrives with transaction time 3 unit(s).
	Customer #4 waits in the customer queue.
	Customer #4 gets teller #2 for 3 unit(s).
---------------------------------------------------------------
Time  : 6
Queue : 0/2
	No new customer!
	Customer #1 is done.
	Teller #1 is free.
---------------------------------------------------------------
Time  : 7
Queue : 0/2
	Customer #5 arrives with transaction time 3 unit(s).
	Customer #5 waits in the customer queue.
	Customer #5 gets teller #1 for 3 unit(s).
---------------------------------------------------------------
Time  : 8
Queue : 0/2
	Customer #6 arrives with transaction time 5 unit(s).
	Customer #6 waits in the customer queue.
	Customer #4 is done.
	Teller #2 is free.
	Customer #3 is done.
	Teller #3 is free.
	Customer #6 gets teller #2 for 5 unit(s).
---------------------------------------------------------------
Time  : 9
Queue : 0/2
	No new customer!
---------------------------------------------------------------
Time  : 10
Queue : 0/2
	No new customer!
	Customer #5 is done.
	Teller #1 is free.

===============================================================

	*** End of simulation report ***


		# total arrival customers : 6
		# customers gone away     : 0
		# customers served        : 6


	*** Current Tellers info. ***


		# waiting customers : 0
		# busy tellers      : 1
		# free tellers      : 2


		Total waiting time   : 0
		Average waiting time : 0.00


	*** Busy Tellers info. ***


		Teller ID                : 2
		Total free time          : 2
		Total busy time          : 8
		Total # of customers     : 3
		Average transaction time : 2.67


	*** Free Tellers Info. ***


		Teller ID                : 3
		Total free time          : 5
		Total busy time          : 5
		Total # of customers     : 1
		Average transaction time : 5.00

		Teller ID                : 1
		Total free time          : 2
		Total busy time          : 8
		Total # of customers     : 2
		Average transaction time : 4.00


Compile and run program

javac simulator/*.java && java simulator.BankSimulator

About

Bank simulation program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages