You can put this solution on YOUR website! Let's john age be "J" and Fred age be "F".
john is presently 12 years older than fred : J = F + 12 .. equation 1
four years ago john was twice as old as fred: (J-4) = 2(F-4).. equation 2
Put equation 1 into equation 2:
(F+12)-4 = 2(F-4)
F + 12 - 4 = 2F - 8
F + 8 = 2F - 8
8 + 8 = 2F - F
16 = F
J = 16 + 12 = 28
John is 28 and Fred is 16 now.