Exercise 2.3

Assignment from Introduction to Java by Y. Daniel Liang.