I have two quantities in my class:
aToday, aYesterday
I have a number X between 1 and 100 entered by user.
Say he enters 10.
What I want to do is to find out if aToday is 10 percent more then aYesterday or 10 percent less then aYesterday.
How to write this ?
I am not getting 10 percent less. X percent more will be:
if(aToday > (x/100 * aYesterday))
How to check for 10 percent more ?
10% more:
10% less
Of course make sure you are calculating with for example
doubleinstances and notintinstances, or you will have unexpected results due to the roundingEdit
For a percentage x
x more (for example x = 10 -> 10 percent more)
and x less
The remark about using the correct types remains of course valid