Finished code for Chapter4 quiz 4, named as Chapter4T4.java