Sixth assignment from "Introducing Java"