percentage
#1

Hello, next, I am attending a problem..

Quote:

TaxaImposto = 15%
AccountData[i][pSalario] = $5000

have to remove 15 percent of 5000, withdrew $ 750 (15%) of 5000, but I do not know about using the percentage.

First attempt:
PHP код:
new valor AccountData[i][pSalario]*TaxaImposto/);
AccountData[i][pSaldoBancario] -= valor
second attempt:
PHP код:
new Valor = (AccountData[i][pSalario]*TaxaImposto) / (Taxa);
AccountData[i][pSaldoBancario] -= Taxa
It was functional, why, what is the correct way to use the percentage using the above functions?
Reply
#2

Should throw in more random pays to check that it is indeed correct. Rather than simply using 1 value of 5000.

And compare it with a calculator.


And when you do it with the calculator, be sure that it is actually doing it correctly. Cheap calculators are common to fault in percentages.

That's why when shop clerks are calculating product tax, they don't use the percent button at all, they divide the whole number, then times by another number to get their result.

(I can't remember the way we used to do it in my old work, as they've changed the tax rate from 12.5 to 15, so whatever I could remember, would lead you wrong, but we used to divide the "actual internal price" by like, 8 or something, then times that by 9, and that would give us our tax inclusive price for the customer. (That would be on a 12.5% markup, if it were even remotely close to being correct via recall)


Even maybe plot out comparisons of various prices on a spreadsheet and get that to check it. Spreadsheet would more likely pull the % not a problem, and would likely be accurate as long as the formula it recieved is correct.



MOAR NUMBERS! The count, wants MOAR...


Your first seems more right than the second... The second is grabbing a value that's not being altered at all, where the first is actually checking against the main value.
Reply
#3

per cent is French and literally means: per hundred. If you keep that in mind it isn't all that difficult.

Add percentage:
pawn Код:
newvalue = oldvalue * (1.0 + (15.0 / 100.0));
Subtract percentage:
pawn Код:
newvalue = oldvalue * (1.0 - (15.0 / 100.0));
Reply
#4

Would you agree Vince, that looking at the First scenario and the Second, the Second has a problem that any value that's put in, the value will still output the same.


new valor, yet that's not returned, it's the taxa which is used.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)