Updated solution for Number3 Java