Working with Percentage

Discussion in 'Plugin Development' started by mrCookieSlime, Dec 27, 2013.

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

    mrCookieSlime

    Hey, I didn't make anything with Bukkit for a while. But since I started again now, I already ran into an issue.

    I just have a simple Question:

    How can I get percent of an Integer.
    I dont mean: (int) number * 100.0 / total
    I mean like get 43% of an Integer.

    How can I do that?

    Also: I know it's simple Calculating in Java and not really Bukkit related. So please move this Thread if it's in the wrong category :)
     
  2. Offline

    ThunderWaffeMC

    This shouldn't be in the Bukkit forums but this should work, shouldn't it?

    Code:java
    1.  
    2. double thePercentage = 0.03;
    3. double theAmount = 150.00;
    4. int finalNumber = Math.floor(MyAmount*Percentage);
    5.  
     
  3. Offline

    mrCookieSlime

    ThunderWaffeMC

    Thanks,

    I know but I often use this Forum to ask questions about Java :3
    Seems like I seriously should have paid attention on the Mathematic lessons in the 7th grade xD
    But anyway thanks :)
     
  4. Offline

    ThunderWaffeMC

    That's okay! Yes you should have paid attention, haha!

    Anyway, most people don't like you asking questions here about Java. They really only want to deal with the Bukkit API.
     
  5. Offline

    mrCookieSlime

    ThunderWaffeMC
    I anyway did this 2 times or so and even in Offtopic P:

    Also: If you see it like this, it is actually not just so Offtopic as it might seem, since I need this for a Bukkit Plugin :3
     
Thread Status:
Not open for further replies.

Share This Page