Short Java program based on this codingbat exercise: http://codingbat.com/prob/p140485