Question: Design a function called display _ charges that calculates the final bill for an online shopping site. The function should take the following arguments where
Design a function called displaycharges that calculates the final bill for an online shopping site. The function should take the following arguments where numeric values are assumed to be nonnegative:
the purchase price ie $
the tax rate ie tax rate
a boolean value representing site membership True if buyer is a member, False otherwise
a discount code that should be one of: FIRSTPURCHASE, FREQUENTBUYER, NODISCOUNT. Any other values would not be valid discount codes.
the country being shipped to ie Canada
The function should print a report of the charges according to the following rules:
if the buyer is a member or they are shipping within Canada they recieve free shipping
shipping is calculated as percent of the amount before discounts and tax
the discounts codes should be applied to the amount of the purchase, to a minimum of as follows:
FIRSTPURCHASE is $ off the purchase price
FREQUENTBUYER and they are a site member it is $ off the purchase price
NODISCOUNT or an invalid discount code is $ off the purchase price
tax is calculated on the amount after the discount is applied
For example, if the function was called as follows:
displaycharges False, 'FIRSTPURCHASE', 'Mexico'
The ouput should be in the exact format notice each item is on a new line and prices printed to two decimal places:
price: $
tax: $
shipping: $
total charge: $
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
