You have just finished eating your Chinese food, and the waiter has brought you the bill.
You note the untaxed total on the bill, given as an int in total.
Additionally, you know the tax rate in your locale, given as an int in taxPercent.
Lastly, you have counted how much money you have, given as an int in money.
Since you feel the service was excellent, you want to give as large a tip as you can afford. You are to return the largest integral value of tip such that:
total + floor(total*taxPercent/100) + floor(total*tip/100) <= money
If there is no non-negative value of tip that satisfies the above inequality, return -1 (you don't have enough money to pay the bill and tax).
|