You only need two formulae. Gravitational field of a spherically symmetric mass distribution is given by $$g = \frac{GM}{R^2},$$ where $M$ is the mass inside a radius $R$. The second formula is the average density of a sphere is its mass divided by its volume, hence $$\rho = \frac{M}{(4/3)\pi R^3}$$
These two formulae can obviously be put together to give the gravitational field as a function of mass and density. $$ g = \frac{GM}{(3M/4\pi \rho)^{2/3}}$$ $$ \rho = \frac{3}{4\pi} g^{3/2} M^{-1/2} G^{-3/2}$$
Using $g=24.8$ m/s$^{2}$ for the surface gravity of Jupiter and $M=6\times10^{24}$ kg for the (unchanged) mass of the Earth. We obtain $\rho = 22096$ kg/m$^{3}$.
Note that my answer assumes that the mass of the Earth is fixed. If you instead change the mass and leave the radius fixed: $$ \rho = \frac{3g}{4\pi G R}$$ which gives $\rho = 13930$ kg/m$^{3}$.
You can't leave mass and radius fixed!