-1
Good evening, folks, the story and the following: a command of value of 100 real, divided by 3 people would be 33.33333, using toFixed(2) and returns 33,33(and one of the objectives), but when you do the sum of these values to confirm is in this example missing 1 cent.
how could I do to determine how many people would have to receive the extra pennies for the account to close. Ex1: value of 100/3 = cliente1: 33.34, cliente2: 33.33 and cliente3: 33,00 Ex2: value of 100/7 = each customer would be with 14.28 and adding this value is 99.96 (where the 4 cents went)
Note: I have already researched, in fact. I did not get an answer to the problem
that cheap people claimed 1 cent credo... leaves to the waiter! D
– Ricardo Pontual
people will not receive the pennies that are left over equally (that is if it is not only 1 cent), because it does not play everything for a single customer?
– Ricardo Pontual
So Father, I thought about this solution too, but depending on the value and quantity of the divisor, this value of 1 cent can vary.
– Bruno Guedes
To close account, someone will have to pay these extra cents, will never be totally "fair". In case you have 4 cents left, you decide if you can give one to pay everything or if you give one penny to 4 "lucky" (that is, 6 people pay 14.28 and one pays 14.32, or 3 pay 14.28 and 4 pay 14.29), or any other criteria you want (1 pays 1 cent and another pays 3, or 2 people pay 2 cents more, I don’t know, you have to choose a criterion of distribution of the cents that are left)
– hkotsubo
Add a penny to one of the 3 and you’re done.
– Edu Mendonça