exercise 1.8 - feel free to edit/improve!
exercise 1.8 - java equivalent, c++ equivalent?