To find the number of students who play at least one of the games, we need to add the number of students who play only football and the number of students who play only the other game, and the number of students who play both games.
Let F be the set of students who play football, and let O be the set of students who play the other game. We are given that |F| = 16, |O| = 12, and |F ∩ O| = 5.
The number of students who play only football is |F - (F ∩ O)|, which is 16 - 5 = 11.
The number of students who play only the other game is |O - (F ∩ O)|, which is 12 - 5 = 7.
Therefore, the number of students who play at least one of the games is |F ∪ O| = |F| + |O| - |F ∩ O| = 16 + 12 - 5 = 23.
Since there are 31 students in the class, the number of students who do not play either game is 31 - 23 = 8.