+ 1
Is this code correct for printing a percentage ?!
2 odpowiedzi
+ 5
Kilometers Inmorales the linked code has it correct. If you are trying to find x percentage of price y, then (y*x/100) will do it.
To remember this, consider the root meaning of the word:
Per Cent means Per 100.
Per implies division, so... divide... x by 100.
That gives you the decimal version of a percent. Now multiply by the price, y, that you want to change by x percent. ("by" implies multiply).
y*x/100
That gives you the new price adjusted by the percent.
+ 1
Isn't it supposed to be (x / y * 100) where x is perc ?!