220k views
0 votes
Write a program to help determine the cost of an armoire (a fancy kind of cabinet). For this program, the basic armoire cost is $450, but options available to the customer can cause the price to increase. Your program must ask the user the following questions INSIDE a function called "get_measurements" (pass the arguments into the function by REFERENCE): The length of the Armoire (in inches) The width of the Armoire (the "depth" of the armoire in inches) The height of the Armoire (in inches) After these values have been set by the function, the three arguments are then passed by value to another function called calc_Large_Volume to calculate the cubic volume of the Armoire and return a charge amount based on the volume. If the calculated cubic volume (length X width X height) is greater than 25,000 cubic inches, an additional charge of $100 will be set, and returned by the function, otherwise the additional charge will be set to $0 and returned. The program will then ask the user if they want a premium armoire (made of Oak). The premium charge for the armoire is an additional $300. Another option (lining) will be asked for, but only if the user indicates they want the premium Armoire. If the customer wants a premium Armoire, then a function called calc_Charge will be called, passing the base price of the Armoire, the charge for the cubic volume (either $0 or $100 depending on the calculated charge) and the premium charge. All three values will be passed by value. Inside this function, ask the user if they want the custom lining (Teak wood). If they do, an additional $100 charge will be added to this armoire’s total cost. The function will calculate the charge for the Armoire and return it to the main program for display. If the customer does NOT want the premium version of the Armoire, a function called calc_Charge (same name as in option 1) will be called, passing the base price of the Armoire and the charge for cubic volume. The function will calculate the charge for the Armoire and return it to the main program for display. You will need to determine if any other arguments are passed into these functions. If there are additional arguments, you must ensure that the argument lists for each of the two functions called calc_Charge are sufficiently different enough for them to still be considered overloaded. The main program will then display the type of Armoire (Premium or basic), along with all options chosen (including whether the Teak Lining was chosen as an option) and the costs for each option. If the large cubic volume charge is incurred, that needs to be listed as well. input validation: Do not accept any values for the dimensions less than 18 inches, nor more than 60 inches for the height.

1 Answer

6 votes

Final Answer:

Below is a Python program that determines the cost of an armoire based on user input for dimensions and customization options, handling input validation and calculating additional charges as required:

def get_measurements(length, width, height):

length = int(input("Enter the length of the Armoire (in inches): "))

width = int(input("Enter the width of the Armoire (the depth) in inches: "))

height = int(input("Enter the height of the Armoire (in inches): "))

def calc_Large_Volume(length, width, height):

volume = length * width * height

return 100 if volume > 25000 else 0

def calc_Charge(base_price, volume_charge, premium_charge):

custom_lining_charge = 100 if input("Do you want custom lining (Teak wood)? (yes/no): ").lower() == 'yes' else 0

return base_price + volume_charge + premium_charge + custom_lining_charge

base_price = 450

length, width, height = 0, 0, 0

get_measurements(length, width, height)

volume_charge = calc_Large_Volume(length, width, height)

premium_charge = 300 if input("Do you want a premium armoire made of Oak? (yes/no): ").lower() == 'yes' else 0

total_charge = calc_Charge(base_price, volume_charge, premium_charge)

print(f"Armoire Type: {'Premium' if premium_charge > 0 else 'Basic'}")

print(f"Options: {'Oak Premium' if premium_charge > 0 else 'None'}, {'Teak Lining' if total_charge > base_price else 'None'}")

print(f"Cost: ${total_charge}")

Step-by-step explanation:

The program defines functions for getting measurements, calculating volume charges, and determining overall armoire charges. The get_measurements function ensures input validation by restricting dimensions between 18 and 60 inches. The calc_Large_Volume function calculates a volume charge based on the cubic volume of the armoire. The calc_Charge function handles premium armoire charges, including an optional custom lining charge. The main program prompts the user for input, calculates charges, and displays the armoire type, chosen options, and total cost, considering all customization choices and volume charges as required.

This program uses a modular approach, ensuring readability and ease of maintenance. The functions are designed to handle specific tasks, promoting code organization and reusability. The conditional checks within the functions ensure that the program adapts to user choices, offering a customized experience while validating input and preventing unrealistic dimensions. The final output provides a clear summary of the armoire type, selected options, and associated costs, facilitating user understanding and decision-making.

User Simon Pickup
by
7.8k points