Fourth assignment from "Introducing Java"