Mixed transactions
Input
compute_total_fee([(CreditCard(), 10000), (PayPal(), 2000), (BankTransfer(), 5000)])
Output
288
CreditCard: 2% of 10000 = 200. PayPal: 2.9% of 2000 = 58 + 30 = 88. BankTransfer: 0. Total = 200 + 88 + 0 = 288 cents.
Full lesson preview
Design a class hierarchy for payment methods and implement polymorphic fee calculation across subclasses.
Problem statement
Task
Examples
Input
compute_total_fee([(CreditCard(), 10000), (PayPal(), 2000), (BankTransfer(), 5000)])
Output
288
CreditCard: 2% of 10000 = 200. PayPal: 2.9% of 2000 = 58 + 30 = 88. BankTransfer: 0. Total = 200 + 88 + 0 = 288 cents.
Input format
Output format
Constraints
Samples
Input
compute_total_fee([(LoyaltyCard(), 10000), (CreditCard(), 5000)])
Output
250
LoyaltyCard: CreditCard fee 200 - 50 = 150. CreditCard for 5000 = 100. Total = 250.