1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
brilliants [131]
3 years ago
10

Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length

in feet of the room and the quality of carpet to be used. A choice between three grades of carpet should be given. You should decide on the price per square foot of the three grades on carpet. Your program must include a function that accepts the length, width, and carpet quality as parameters and returns the cost of carpeting that room. After calling that function, your program should then output the carpeting cost. of carpeting a room. Note: the output is NOT in the function but in the main. Display your name,class,date as per SubmissionRequirements by using a function.
Your program should include your design steps as your comments. Document the values you chose for the prices per square foot of the three grades of carpet in your comments as well.
Computers and Technology
1 answer:
allochka39001 [22]3 years ago
8 0

Answer:

In Python:

def calcCost(length,width,quality):

   if quality == 1:

       cost = length * width * 3.50

   if quality == 2:

       cost = length * width * 2.50

   else:

       cost = length * width * 1.50

   

   return cost

   

length = float(input("Room Length: "))

width = float(input("Room Width: "))

print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")

quality = int(input("Quality: "))

print("Calculate: "+str(calcCost(length,width,quality)))

Explanation:

This defines the function calcCost to calculate the carpeting cost

def calcCost(length,width,quality):

If quality is 1, the total cost is calculated by area * 3.50

<em>    if quality == 1:</em>

<em>        cost = length * width * 3.50</em>

If quality is 2, the total cost is calculated by area * 2.50

<em>    if quality == 2:</em>

<em>        cost = length * width * 2.50</em>

For other values of quality, the total cost is calculated by area * 1.50

<em>    else:</em>

<em>        cost = length * width * 1.50</em>

This returns the calculated carpeting cost    

   return cost

   

The main begins here

This prompts the user for the length of the room

length = float(input("Room Length: "))

This prompts the user for the width of the room

width = float(input("Room Width: "))

This gives instruction on how to select quality

print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")

This prompts the user for the quality of the carpet

quality = int(input("Quality: "))

This calls the calcCost method and also printst the calculated carpeting cost

print("Calculate: "+str(calcCost(length,width,quality)))

You might be interested in
Which image file format is the most widely used?
Ostrovityanka [42]

Answer: jpeg because its a lot of people use it for quaity

7 0
2 years ago
Is the willingness to put a customer’s needs above ones own needs and to go beyond a job description to achieve customer satisfa
klemol [59]

Answer:

customer-serious orientation

Explanation:

Customer-serious orientation can be defined as the willingness to put a customer’s needs above ones own needs and to go beyond a job description to achieve customer satisfaction.

This ultimately implies that, a customer-serious oriented business firm or company puts the needs, wants and requirements of its customers first without considering their own needs in a bid to satisfy and retain them.

Hence, customer-serious orientation requires the employees working in an organization to show and demonstrate positive attitudes and behaviors at all times.

6 0
3 years ago
Assume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single s
Alik [6]

array[0] = 2 * array[4];

5 0
3 years ago
Anyone have an answer for 4.9 lesson code practice
castortr0y [4]

Answer:

loop

Explanation:

4 0
3 years ago
What is the definition for Types of Resource-Community Resources??​
exis [7]
Typically, when someone refers to a community resource, they mean an organization that serves a particular geographical area or group of people by providing tools to help that community grow in positive ways and improve the quality of life for the people of that community.
4 0
3 years ago
Other questions:
  • when applying styles to a document, which features of the style can be modified in the themes grouping?
    9·2 answers
  • Suppose you have two arrays of ints, arr1 and arr2, each containing ints that are sorted in ascending order. Write a static meth
    7·1 answer
  • Insurance can help you:
    10·1 answer
  • You would like to set up on online meeting to communicate with colleagues on a group project. Which of these tools should you su
    5·2 answers
  • Need help with this
    12·1 answer
  • Robert is working on an image as part of his school project. he has to do multiple edits on the file. what is a good practice fo
    8·1 answer
  • From a neural network with 11 input variables, one hidden layer with three hidden units, and one output variable, how many param
    7·1 answer
  • The
    12·2 answers
  • Help Me Please, Ill mark whoever has the best answer with brainliest.
    14·1 answer
  • Tools used to build a bridge<br>​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!