In: Computer Science
PYTHON:
Our glass installation business needs a program that will assist our agents in calculating the installed cost of shower enclosure. This is in particular for 90 degree glass shower enclosures.
The program will get the depth (B), width (A) and height (C) of the shower base as shown on the diagram on the right. Program also needs to get the thickness of the glass as that affects the price. All input are in inches.
For a 90-degree shower enclosure, we need 2 panels of glass. Area of panel 1 is depth times height. Area of panel 2 is width times height. If area of both panels is larger than (and equal to) 6000 inches square, unit price per square inch is $0.99. If it is less than 6000 square inch, then the per unit square price of glass is $1.29. For any enclosure that requires less than 3000 square inch, the unit price is $1.49.
(60 points) Based on the unit price and the area of glass needed to complete the job we can compute the installed price of the enclosure. There is, however, 50% surcharge if the thickness of the glass is larger than (or equal to) 0.5 inches. Otherwise, if the thickness of the glass is larger than (or equal to) 0.375, the surcharge is 20%.
(60 points) Finally we need to ask user for a discount code. Discount code is a numeric code -- we support two codes. If user enters discount code 112233, we apply 20% discount to the total price. If user enters discount code 111222, we apply 10% discount to total price. If no code, user should enter 0. Any other code should result in invalid discount code message and the calculation happen without any discount.
(60 points) At the end of the calculation, your program should give user the ability to compute another shower enclosure or exit out of the program.
On the left hand side, you can see the program running. Make sure that you have minimum 3 comments in the code and that your code is properly indented (-40 points penalty).
def run():
depth = float(input('Enter depth: '))
width = float(input('Enter width: '))
height = float(input('Enter height: '))
thickness = float(input('Enter thickness: '))
area_panel_1 = depth * height
area_panel_2 = width * height
unit_price = 1.49 # unit price to be applied, based on total
area
if area_panel_1 + area_panel_2 >= 3000:
unit_price = 1.29
if area_panel_1 + area_panel_2 >= 6000:
unit_price = 0.99
surcharge = 0 # surcharge to be applied, based on
thickness
if thickness >= 0.375:
surcharge = 0.2
if thickness >= 0.5:
surcharge = 0.5
discount_code = input('Enter discount code: ')
discount = 0 # discount to be applied based on discount code
if discount_code == '112233':
discount = 0.2
elif discount_code == '111222':
discount = 0.1
elif discount_code != '0':
print('Discount code is invalid!')
basic_price = unit_price * (area_panel_1 + area_panel_2) # basic
price just considering unit price and area
surcharged_price = basic_price + surcharge * basic_price # apply
surcharge on top of basic price
final_price = surcharged_price - discount * surcharged_price #
apply discount on surcharged price to get final price
print('Price:', final_price)
while True:
choice = int(input('Enter 1 to calculate price, 2 to exit:
'))
if choice == 1:
run()
elif choice == 2:
break