General Solution for Hamiltonians with Extended Cubic and Quartic Potentials