Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started