Andy's age = x
Jeff's age = x-2
Andy's age in five years = x+5
Jeff's age in five years = x-2+5
The sum of their ages in five years = x+5 + x-2+5
x + 5 + x - 2 + 5 = 40
2x + 8 = 40
-8 -8
2x = 32
:2 :2
x = 16
x - 2 = 14
Andy is 16 years old and Jeff is 14 years old