Let Babs be X years old then Julia is X+5.
Now you can add the 2 ages and the sum is 31 and you solve for X
X + X + 5 = 31
2X + 5 = 31
2X = 26
X = 13
Always go back and check your work, Babs is 13, and Julia is 5 years older so she is 18, and 18 & 13 add to 31.
All the best
Lori