Code in the main method

(Display Listing 1.)

The code in the main method consists of a sequence structure containing three actions:

  1. A statement that calls the world method named NumberDialog to get input from the user and to store that input in the variable named userInputValue (See Figure 4.)
  2. A statement that calls the world method named Math.IEEERemainder to compute the remainder after dividing the user input by 2.  This statement also tests the remainder to see if it is equal to 0.  The true or false result is stored in the Boolean variable named testResult.
  3. A selection structure that uses the result of the test in the second action above to determine whether to display the word Even or the word Odd.

A bug in IEEERemainder function
Sometimes the function returns the correct answer and sometimes it returns the wrong answer. On the basis of a very limited amount of experimentation, it seems to return the correct answer for those cases where the correct answer is 0.