The terms "inclusive" and "exclusive" are qualifiers that apply to the endpoints of a range. "Inclusive" means that the number that specifies an endpoint of the range is included in that range. "Exclusive" means that a number is not included.
The "inclusive range of 2 to 5" means that the following integers are in the range: 2, 3, 4, 5. In mathematical notation, we write such a range as [2, 5] (using square brackets).
If the bounds of the range were exclusive, only the integers 3 and 4 would be in range. In mathematical notation, such a range would be written (2, 5) (using parentheses).
Note that the bounds of a range can have differing qualifiers. "The range of 2 (inclusive) to 5 (exclusive)" means the integers 2, 3 and 4 are in range. This is written [2, 5).
In Java, it is convention that the left bound of a range is inclusive and that the right bound is exclusive, so "from 2 to 5" usually means that the 2 is included and the 5 is excluded. For this reason, the assignment explicitly specifies that the 5 is included as well.
Most ranges in computer sciences are defined on the inclusive‑exclusive basis. Look at this method. Look at the names of the method parameters, which aree particularly helpful in this case. And now look at this method, which is subtly different.
On the inclusive‑exclusive basis, 0...10 includes 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
On the inclusive basis, 0...10 includes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10.
I think the question you quoted was poorly worded, and I also think it is possible to write a much simpler solution that will fulfill all its requirements. I think the question is less about writing if‑elses than about Boolean algebra.
Challenge: find the shortest and simplest solution.
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, that will fit in a stocking