Williams Posted August 14, 2022 Posted August 14, 2022 I'm creating a percentage config for VIP I want them to have 30% discount for teleport but what would be the option in java for integers? For example final int price = 10000 getVip() ? price % 10 : price result = 0 when debugging my value is 0 but it should be 1000
0 @IcathiaLord Posted August 14, 2022 Posted August 14, 2022 You using % = mod (modulo), that means number 10.000 divined with 10, will have a result of 1.000 and 0 remaining. Another example: 11 mod 4 = 3, because 11 divides by 4 (twice), with 3 remaining. You can take the 30% percentage by the following: int finalPrice = (int) (getVip() ? (price - price * 0.30) : price); 1
0 Williams Posted August 14, 2022 Author Posted August 14, 2022 3 hours ago, @IcathiaLord said: You using % = mod (modulo), that means number 10.000 divined with 10, will have a result of 1.000 and 0 remaining. Another example: 11 mod 4 = 3, because 11 divides by 4 (twice), with 3 remaining. You can take the 30% percentage by the following: int finalPrice = (int) (getVip() ? (price - price * 0.30) : price); thank you i get it
0 Zake Posted August 15, 2022 Posted August 15, 2022 23 hours ago, Williams said: thank you i get it Topic locked.
Question
Williams
I'm creating a percentage config for VIP I want them to have 30% discount for teleport but what would be the option in java for integers? For example
final int price = 10000
getVip() ? price % 10 : price
result = 0
when debugging my value is 0 but it should be 1000
3 answers to this question
Recommended Posts