You need to sign in to do that
Don't have an account?
Joe Hayes
Decimal Multiplier Problem
This might be simple but I don't know why it doesnt work.
However this...
Decimal pricePerPerson = 100.00; Decimal sellPerPerson = 1.1764705882352 * pricePerPerson; sellPerPerson = sellPerPerson.setScale(2);This returns 117.65 as expectd.
However this...
Integer discountPercent = 15; Decimal pricePerPerson = 100.00; Decimal sellPerPerson = (100/(100-discountPercent)) * pricePerPerson; sellPerPerson = sellPerPerson.setScale(2);returns 100.00 and I'm not sure why. It should also return 117.65
As discountPercent is declared as Integer so (100/(100-discountPercent)) is returning Integer Value which is 1 and it is multipled with 100.00 gives you 100.00.
Instead of that define discountPercent as decimal then you will get required result.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Please use below code :-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Or you can use below:- both of code is tested my side
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
As discountPercent is declared as Integer so (100/(100-discountPercent)) is returning Integer Value which is 1 and it is multipled with 100.00 gives you 100.00.
Instead of that define discountPercent as decimal then you will get required result.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,