[Solved] Think java chapter 3 exercise 3-4 – Guess My Number


I think what you are confused about is the modulo operation. At least the text does not fit to what it is doing. To calculate what was the difference between the two numbers you would just do

difference = numberGenerated - numberGuessed;

When you don’t want to have negative values you could use

difference = java.lang.Math.abs(numberGenerated - numberGuessed);

The modulo operator gives you the rest of a division.

0

solved Think java chapter 3 exercise 3-4 – Guess My Number