143k views
1 vote
/* Return true if the given non-negative number is 1 or 2 less than a

* multiple of 20. So for example 38 and 39 return true, but 40 returns false.
*/
public boolean less20(int n) n % 20 == 18;


User Ordiel
by
8.4k points

1 Answer

2 votes

Final answer:

The question involves a Java method that checks if a non-negative integer is 1 or 2 less than a multiple of 20 by using a modulus operation.

Step-by-step explanation:

The student's question pertains to the evaluation of a conditional statement in a Java method. The purpose is to determine whether an input non-negative number is either 1 or 2 less than a multiple of 20. The provided code uses the modulus operator (%) to check the remainder when the input number is divided by 20.

If the remainder is 19 or 18, it signifies that the number is 1 or 2 less than a multiple of 20 respectively, and the method returns true. If the remainder is any other number, it means that the condition is not met and the method should return false.

User Akeelah
by
8.2k points