Second assignment from "Introducing Java"