20.1k views
5 votes
Display the cost of landscaping a backyard with sod that is sold by the square foot and fencing that is sold by the foot. The input will be the length and width of the backyard, the price of sod per square foot and the price of fencing per foot.

User Jdepypere
by
4.5k points

1 Answer

3 votes

Answer:

length = float(input("Enter length of the backyard in foot: "))

width = float(input("Enter width of the backyard in foot: "))

sod_price = float(input("Enter the price of sod per square foot: "))

fencing_price = float(input("Enter the price of fencing per foot: "))

area = length * width

perimeter = 2 * (length + width)

cost = sod_price * area + fencing_price * perimeter

print("The cost of landscaping is $" + str(cost))

Step-by-step explanation:

*The code is in Python.

Ask the user to enter the length, width, sod_price, and fencing_price

Calculate the area and perimeter of the backyard

Calculate the cost, sod_price * area + fencing_price * perimeter

Print the cost

User Andre Soares
by
4.6k points