I want to find value by a percentage on a particular value.
For example
Scenario 1
10 * 75% = 7.5
Scenario 2
20 * 75% = 15
So I tried this but gave an error. So anyone how to solve this?
CodePudding user response:
The %
symbol in Kotlin, and many other languages, isn't actually used for percentages. It's the symbol for the 'modulo' operator, and does something different from what you want.
To calculate a percentage, divide the value by 100.
For example, 75% of 10 is 10 * 0.75
.