Let J be John’s age. Tom is J+6 years old. Sam is J-5 years old.
The sum of their ages is J+J+6+J-5=83, 3J+1=83, 3J=82, so J=82/3=27⅓. That would make Tom 33⅓ and Sam 22⅓. When we add their ages together 27⅓+33⅓+22⅓=82+1=83.
It’s unlikely that fractional ages would be the solution, so please check the details of the question.
If the sum of their ages had been 82, then their ages would have been 27, 33 and 22.