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 display_charges that calculates the final bill for an online shopping site. The function should take the following arguments where numeric values are assumed to be non-negative:
the purchase price (ie. $ 15.99)
the tax rate (ie.8% tax rate)
a boolean value representing site membership - True if buyer is a member, False otherwise
a discount code that should be one of: FIRST_PURCHASE, FREQUENT_BUYER, NO_DISCOUNT. 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 10 percent of the amount before discounts and tax
the discounts codes should be applied to the amount of the purchase, to a minimum of 0, as follows:
FIRST_PURCHASE is $ 10 off the purchase price
FREQUENT_BUYER and they are a site member it is $ 2 off the purchase price
NO_DISCOUNT or an invalid discount code is $ 0 off the purchase price
tax is calculated on the amount after the discount is applied
For example, if the function was called as follows:
display_charges(22.0,8, False, 'FIRST_PURCHASE', '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: $ 12.00
tax: $ 0.96
shipping: $ 2.20
total charge: $ 15.16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!