Solved Maths help (int value in correspondence to another value)

Discussion in 'Plugin Development' started by SuperOriginal, Jul 8, 2014.

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

    SuperOriginal

    So i'm developing a plugin in which a player's "level" (int) determines another double's value. Every 100 "levels" the double increases by 25. Does anybody know how to do this without manually increasing every increment? (ex. (if(lvl >= 100 && lvl <= 200)...) Thanks :D
     
  2. Offline

    JasonDL13

    Probably something like. double = double + (25 * (int / 100))

    Not sure if that works or if it's formatted correctly
     
  3. Offline

    SuperOriginal

    I don't think that works, but it gave me an idea to retrieve the first digit of the number, and multiply that by 25. I'll see if that works.
     
  4. Offline

    dsouzamatt

    SuperOriginal Whenever a player increases their int level by a point, do something like this:
    Code:java
    1. if(intLevel%100 == 0)
    2. {
    3. doubleLevel = doubleLevel+25;
    4. }

    I've used the modulus operator (%). This returns the remainder when two numbers are divided.

    In the code above, if the player's intLevel divided by 100 leaves a remainder of 0 (intLevel%100 == 0), they must have reached a new level, so 25 is added to the doubleLevel variable.
     
  5. Offline

    SuperOriginal

    dsouzamatt likes this.
Thread Status:
Not open for further replies.

Share This Page