Empirical Lab Repository

Title: Queues and a Bank Simulation

Author: Dave Reed, Creighton University, davereed@creighton.edu

Possible Courses: CS2

Empirical Concepts Introduced: simulation, analytical reasoning

Computer Science Concepts Used: class use, class implementation, data abstraction, queues

Summary: This assignment involves writing a program to simulate customer interactions at a small bank. The bank is assumed to have only a single teller, with customers arriving at random times and served in a first-come-first-served order. Classes are provided for modeling the teller and customers, as well as the main program for simulating a period of banking. The student is asked to complete the implementation of a ServiceCenter class, which contains a Teller object and is used to service Customers as they arrive. A queue is used to hold and serve waiting customers. As part of the assignment, the student must extend the ServiceCenter class to maintain statistics on the simulation. Through experimentation, they must answer questions about the behavior of the simulation under various conditions.

While the amount of code required for this assignment is not that much, its development requires understanding the behavior and interaction of multiple classes. In addition, the simulation provides an intuitive, real-world application of queues.

Variations: This assignment can be extended in a variety of ways. A natural one is to extend the number of tellers in the bank. This can be accomplished by having a separate line for each teller (i.e., a vector of queues), or a single queue that feeds all tellers. Student may be asked to implement these two approaches and then compare their performance (for example, determining which arrangement tends to minimize customer waiting times).