Question

In: Computer Science

PYTHON: Our glass installation business needs a program that will assist our agents in calculating the...

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).

Solutions

Expert Solution

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


Related Solutions

Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
language: python A local biologist needs a program to predict population growth. The inputs would be:...
language: python A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms, as an int The rate of growth (a real number greater than 1), as a float The number of hours it takes to achieve this rate, as an int A number of hours during which the population grows, as an int For example, one might start with a population of 500 organisms, a growth rate of 2, and a...
Python Programming Revise the ChatBot program below. There needs to be one list and one dictionary...
Python Programming Revise the ChatBot program below. There needs to be one list and one dictionary for the ChatBot to use. Include a read/write function to the program so that the program can learn at least one thing and store the information in a text document. ChatBot program for revising: # Meet the chatbot Eve print('Hi there! Welcome to the ChatBot station. I am going to ask you a series of questions and all you have to do is answer!')...
Python code Financial Assistance : A non-governmental organization needs a program to calculate the amount of...
Python code Financial Assistance : A non-governmental organization needs a program to calculate the amount of financial assistance for needy families. The formula is as follows: • If the annual household income is between $30,000 and $40,000 and the household has at least three children, the amount is $1,000 per child. • If the annual household income is between $20,000 and $30,000 and the household has at least two children, the amount is $1,500 per child. • If the annual...
In python Using the example code from the HangMan program in our textbook, create a Word...
In python Using the example code from the HangMan program in our textbook, create a Word Guessing Game of your choice. Design a guessing game of your own creation. Choose a theme and build your words around that theme. Keep it simple. Note: I would highly recommend closely reviewing the HangMan code and program from Chapter 10 before starting work on this project. You can run the program via my REPL (Links to an external site.). Using python Similar to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT