The quick version is to first move everything to one side:
$$q^2+3q-40=0$$
From here, you can factor if you can spot the factors by inspection or if you have difficulty with that you can rely on the quadratic formula. The above is in the form $aq^2+bq+c=0$ where $a=1,~b=3,~c=-40$ which has roots $\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}$. Plugging in the values gives
The quick version is to first move everything to one side:
$$q^2+3q-40=0$$
From here, you can factor if you can spot the factors by inspection or if you have difficulty with that you can rely on the quadratic formula. The above is in the form $aq^2+bq+c=0$ where $a=1,~b=3,~c=-40$ which has roots $\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}$. Plugging in the values gives
$$\dfrac{-3\pm\sqrt{3^2-4\cdot 1\cdot (-40)}}{2\cdot 1} = \dfrac{-3\pm \sqrt{169}}{2}=\dfrac{-3\pm 13}{2}$$
which gives roots $5$ and $-8$, as expected.