Problem
In a shopping mall, based on the user's total purchase amount, return the final price according to the discount rules below.
- Basic Discount
- 5% discount if the total price is at least 100,000 won
- 10% discount if the total price is at least 300,000 won
- 15% discount if the total price is at least 500,000 won
- Membership Level Additional Discount
- Silver: Additional 3% discount
- Gold: Additional 5% discount
- Platinum: Additional 10% discount
- Payment Method Additional Discount
- Credit Card: No additional discount
- Cash: Additional 2% discount
- Special Promotion
- If the total price before applying any discounts is at least 500,000 won, and the customer is a platinum member paying by cash, apply an additional 50,000 won discount.
Discounts are applied sequentially in the order listed. Additional discounts are based on the result of the previous discount step.
Constraints
totalPriceis a natural number between 10,000 and 1,000,000 and is given in multiples of 10,000.membershiprepresents the membership level and is one of "Silver", "Gold", or "Platinum".paymentMethodis the payment method and is either "Credit Card" or "Cash".- The final price should be rounded down to the nearest integer.
Test Case
| Test Case Number | totalPrice | membership | paymentMethod | return |
|---|---|---|---|---|
| 1 | 550000 | "Platinum" | "Cash" | 362335 |
| 2 | 400000 | "Gold" | "Credit Card" | 342000 |
| 3 | 150000 | "Silver" | "Cash" | 135460 |
Explanation for Test Case 1
- Total Price: 550,000 won
- Membership: Platinum
- Payment Method: Cash
Discount application order:
- Basic Discount: Since the total price is 550,000 won, a 15% discount applies, 550000 * 0.85 = 467500
- Membership Discount: Platinum members receive an additional 10% discount, 467500 * 0.90 = 420750
- Payment Method Discount: Cash payments receive an additional 2% discount, 420750 * 0.98 = 412335
- Special Promotion: The total price before discounts is over 500,000 won, the customer is a platinum member, and paid by cash, so an additional 50,000 won discount is applied, 412335 - 50000 = 362335
Therefore, the final price is 362,335 won.
Explanation for Test Case 2
- Total Price: 400,000 won
- Membership: Gold
- Payment Method: Credit Card
Discount application order:
- Basic Discount: Since the total price is 400,000 won, a 10% discount applies, 400000 * 0.90 = 360000
- Membership Discount: Gold members receive an additional 5% discount, 360000 * 0.95 = 342000
- Payment Method Discount: No additional discount for credit card payments
Therefore, the final price is 342,000 won.
Explanation for Test Case 3
- Total Price: 150,000 won
- Membership: Silver
- Payment Method: Cash
Discount application order:
- Basic Discount: Since the total price is 150,000 won, a 5% discount applies, 150000 * 0.95 = 142500
- Membership Discount: Silver members receive an additional 3% discount, 142500 * 0.97 = 138225
- Payment Method Discount: Cash payments receive an additional 2% discount, 138225 * 0.98 = 135460.5
Therefore, the final price is 135,460 won.