Here I took the user answer and subtract the correct answer from it in the parenthesis to apply it to the closeness of the user’s answer. For example, if the user was asked what is 2*8 and the user said 15, the application would perform the subtraction 15 – 16 = -1.
The Math.Abs statement converts any negative number to a positive.
So when seeing 15-16= -1 and the Math.Abs statement converts this to 1, the application can read that the user was 1 away from the correct answer.
Here if else statements can be used to inform the user how close they were to the correct answer, by saying if diff == 1 (being the closest), else if diff <= 10 (being fairly close) and else (being not close at all).