Solved Multiples of Integers

Discussion in 'Plugin Development' started by Zach_1919, Jun 13, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Zach_1919

    Hello Bukkiteers,
    I am further updating my XPJar plugin, and I am adding a simple tax system. Every time a person puts XP into the jar and it passes a configurable interval, I want it to take away a configurable amount. Let's say that the interval is 10 levels and the tax is 1 level. How can I check if an integer is a multiple of a number?
     
  2. Offline

    flaaghara

    Code:java
    1. if(integer % number == 0) {
    2. //do stuff
    3. }


    The % is an operator like +,-,*,/ called a modulus, which gets the remainder of a division. If the remainder of an integer divided by a number is 0, than that integer must be a multiple.

    15 % 5 would give you 0 because 15 / 3 gives you an exact 5. 15 is a multiple of 5.
    Conversely, 15 % 4 would give you 3 because the remainder is 3. So, 15 is NOT a multiple of 4.
     
  3. Offline

    Zach_1919

Thread Status:
Not open for further replies.

Share This Page