-6

I have an if/else statement in my program, and the if statement checks 3 factors, one being if the input given from the user is a multiple of 5, and if it is not, it runs the program. I am currently using the modulus operator, but even when I input a multiple of 5 it still runs the program instead of moving on to the else statement.

Here is my code:

 if(cost == 0) or (cost > 100) or (cost != 100%5):
flaxel
  • 4,173
  • 4
  • 17
  • 30
snaigy
  • 1
  • 2

1 Answers1

0

To check if a number is a multiple of x, use the following code:

number % x == 0

To check if this is not the case, simply replace the "==" with "!=":

number % x != 0

For more information regarding the modulo operation visit the wikipedia

Deric
  • 180
  • 7