Answer
The earthquake was 1200 km away.
Work Step by Step
Let $t_p$ be the time that the P-wave took to reach the seismograph. Let $t_s$ be the time that the S-wave took to reach the seismograph. Note that $t_s = t_p + 120~s$
We can use the P-wave to write an expression for the distance.
$d = v_p~t_p$
$d = (8000~m/s)~t_p$
We can use the S-wave to write an expression for the distance.
$d = v_s~t_s$
$d = (4500~m/s)~(t_p+120~s)$
$d = (4500~m/s)~t_p+540,000~m$
We can equate the two expressions for the distance and solve for $t_p$:
$(8000~m/s)~t_p = (4500~m/s)~t_p+540,000~m$
$(3500~m/s)~t_p = 540,000~m$
$t_p = \frac{540,000~m}{3500~m/s}$
$t_p = 154.3~s$
We can use the P-wave to find the distance.
$d = (8000~m/s)~t_p$
$d = (8000~m/s)~(154.3~s)$
$d = 1.2\times 10^6~m = 1200~km$
The earthquake was 1200 km away.