Question

program language: python 3

Purpose: Solve a problem by writing multiple functions that perform different subtasks, and combining their use to solve a larger problem. Also to practice documenting functions. Degree of Difficulty: Moderate Your task is to compute the cost of renovating the flooring in a rectangular room. This includes replacing the carpet and and the baseboards. Your task is to write a Python program that calculates and the cost of the renovation. To accomplish this, you will need to write three Python functions: cost, carpet, and baseboard. The baseboard function should take parameters width (the width of the room in feet) and length (length of the room in feet). The function will need to obtain the cost of baseboard per linear foot from console input. It will return the total cost of the baseboard. The permimeter of the room is: perimeter = 2 x width + 2 x length and the total cost of the baseboard is perimeter x cost of baseboard per foot The carpet function should take parameters width (the width of the room in feet) and length (length of the room in feet). The function will need to obtain the cost of carpet per square foot from console input. It will retum the total cost of the carpet. The area of the room is: areawidth x length and the total cost of the carpetis area x cost of carpet per square foot The cost function determines the total cost of the project It should call baseboard and carpet and use their return values to compute the total cost. . The total cost will be the cost of materials plus $500 labor The parameters of the cost function should be chosen so that they provide the necessary information required to call the baseboard and carpet functions. Remember to write appropriate docstrings for each function which states their purpose, parameter(s), and retum value(s) You must now test your program by preparing three examples (width, length.cost of baseboard, and cost of carpet) in advance so that you can judge whether your program is correct. Write code ask for the di mensions of the room inputs, then display the total cost of each prepared example to the console. Copy the console output from each of your three testing examples into a text file and hand that text file in (see What to Hand In, below) You may assume that the user supplies valid input from the console. See the sample run on the next page

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PYTHON PROGRAM:

def baseboard(width, length, baseboardCost):
    perimeter = 2*(length + width)
    return perimeter * baseboardCost
def carpet(width, length, carpetCost):
    return (width * length * carpetCost)
width = float(input("What is the width of the room (ft) "))
length = float(input("What is the length of the room (ft) "))
baseboardCost = float(input("Input the cost of a linear foot of baseboard ($) "))
carpetCost = float(input("Input the cost of a square foot of carpet ($) "))
totalCost = baseboard(width, length, baseboardCost) + carpet(width, length, carpetCost) + 500
print("For a room of width", width, "and length", length, "the cost of he reno is $", totalCost)

OUTPUT:

What is the width of the room (ft) 10 What is the length of the room (ft) 20 Input the cost of a linear foot of baseboard (S) 2 Input the cost of a square foot of carpet (S) 10 For a room of width 10.0 and length 20.0 the cost of he reno is s 2620.0

Add a comment
Know the answer?
Add Answer to:
program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants...

    This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants to estimate what it will cost a customer to have a room carpeted. They can carpet 65 sq. ft. of room space in 4 hours, and they charge $25.00 per hour as their labor rate Write a program to ask the user for the length of the room (in inches) to be carpeted, the width of the room (in inches) to be carpeted, and...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • Need to solve this program which will run exactly like sample run .. Thanks Project 2...

    Need to solve this program which will run exactly like sample run .. Thanks Project 2 Using Classes and Objects (Chapter 3) Duc: sec calendar Two files to be submitted: . Algorithm of method main (AlgorithmOfMain.txt, no credit if this is missing) Java Source code (CarpetBill.java- no credit if this has syntax errors) Write a program that creates customers' bills for a carpet company when the information below is given: irst name .Length and width of the carpet in feet...

  • Flowchart 1: Create a flowchart for a program that calculates the total cost of carpeting a...

    Flowchart 1: Create a flowchart for a program that calculates the total cost of carpeting a room. Assume that the room is rectangular. The data required for running the program will be the length of the room, the width of the room, and the cost per square yard of the carpet. When the user runs the program it must, in the following order: Prompt for the length of the room. Prompt for the width of the room. Prompt for the...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • 2. Write a program with three functions that will be called from the main function The functions will calculate the...

    2. Write a program with three functions that will be called from the main function The functions will calculate the volume, area and perimeter of a cuboid. You should able to pass three parameters such as length, width and height, and a function will return area, another will return volume and final one will return perimeter. Define all your variables in floating point numbers 3. Modify the problem#2 to calculate the volume, area and perimeter in a sing le function...

  • A closer look at functions - C++ C option: (The best grade is a 79%) Write...

    A closer look at functions - C++ C option: (The best grade is a 79%) Write a program to calculate the cost and time it takes to fill a swimming pool . Inputs: Length, Width, and Depth of the pool (This is a gross simplification, since pools are not really rectangular cubes.) Fill rate of the pool in Gallons per minute Calculation functions Write a function to calculate the total cubic feet (Length x Width x Depth) and return the...

  • Write this program using python. In your program, when you prompt users for values, only prompt...

    Write this program using python. In your program, when you prompt users for values, only prompt them to enter one value at a time. Here is a sample of what your program should look like. Sample Program Run (User input in bold) What is the length of the room (in feet)? 50 What is the width of the room (in feet)? 30 What is the length of the table (in feet)? 8 What is the width of the table (in...

  • C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer...

    C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer to have a driveway poured. They can pour a 3 inch deep 200 sq. ft. driveway in 3 hours, and they charge $50.00 per hour as their labor rate. Write a program to ask the user for the length of the driveway (in feet), and the width of the driveway (in feet) to be poured. For both the length and width, make sure the...

  • Python Programing : Convert to binary - functions Write a program that takes in a positive...

    Python Programing : Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT