Best attempt at problem 19 solution. Cannot figure out why program will not produce correct results