That's not how switch
blocks work. You would need to do something like this instead:
switch (Essais) {
case 20:
...
case 40:
...
case 60:
...
/* etc, etc */
}
Each case
compares the value in the switch
statement against a specific constant value. If they are equal, that block is executed. In your code, the compiler is complaining because an expression like Essais<=20
is not a constant that it can evaluate at compile time.
Given what you are trying to do, an if ... else if ... else
chain would be more appropriate. switch
blocks can only test against specific values and can't handle testing ranges, which is what it appears you are trying to do.