Update Solution3.java

Redid solution to make use of return instead of nesting if structures.