Problem Statement
PROBLEM STATEMENT Stingy Susan takes her boyfriend QuteBits out to dinner and a movie. At the end of the meal, she gets a bill listing what they ate and what the subtotal is (the rest is normally handled at the register). Since they are running a bit late for the movie, she elects to just leave cash at the table. Susan knows the applicable sales tax in this area, and also has a pretty good idea how generous a tip the waitron deserves. However, she has no change on her; but, enough in bills to make any amount that she will need to pay tonight. Given a subtotal (expressed in cents), the percentage sales tax, and the percentage tip she wants to leave, pick the nearest whole dollar amount that will cover the bill. Sales tax is rounded to the nearest cent; exact half-pennies round up. Tip amount is based on the subtotal before tax. (The subtotal and tax must be paid in full, regardless of how poor the service was.) If there are two distinct amounts Susan could pay that come equally close to leaving the desired tip, select the lowest possible... she is called Stingy for a reason. DEFINITION Class Name: Dinner Method Name: payForMeal Parameters: int, int, int Returns: int Here is the method signature (make sure your method is public): int payForMeal(int subtotal, int sales_tax_percent, int tip_percent); TopCoder will ensure the following: * subtotal will be between 0 and 1000000, inclusive. * sales_tax_percent will be between 0 and 100, inclusive. * tip_percent will be between 0 and 100, inclusive. EXAMPLES payForMeal(0, 5, 20) = 0 payForMeal(89, 10, 40) = 1 payForMeal(1995, 6, 0) = 22 payForMeal(1000, 5, 20) = 12 payForMeal(2385, 7, 16) = 29 payForMeal(2385, 7, 17) = 30 payForMeal(13500, 0, 50) = 202
Definition
- Class:
- Dinner
- Method:
- payForMeal
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int payForMeal(int param0, int param1, int param2)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.