My solution to http://rubyquiz.com/quiz2.html in Java