[SOLVED] How Much SOS HELP

Here is the code:

# Calculate the perimeter and the area of the garden
# and pay the fair price for that.

# The prices for fences and lawns.
fencePrice = 3 # per meter.
lawnPrice = 2 # per square meter.
# You need the foreman.
foreman = hero.findNearest(hero.findFriends())
corners = foreman.corners
# Get the information about the garden.
bottomLeft = corners.bottomLeft
topRight = corners.topRight
# Calculate the size of the garden.
width = topRight.x - bottomLeft.x
height = topRight.y - bottomLeft.y
# Find the perimeter of the garden (meters):
perimeter = (width + height) * 2
# Use fencePrice and calculate the fence cost:
fencePrice = 3 * perimeter
# Find the area of the garden (square meters):
area = width * height 
# Use lawnPrice and calculate the lawn cost:
llawnPrice = area * 2

# The total cost is the sum of the fence and the lawn costs
totalCost = 0 # Δ Update this with the final price!
totalCost = lawnPrice + fencePrice
hero.say("The total price is " + totalCost)
# Pay the bill.
foreman.bill(totalCost)

1 Like

did you misspell lawnPrice in

llawnPrice = area * 2

?

1 Like

oh - youre also redefining your variables in these lines:

fencePrice = 3 * perimeter
# Find the area of the garden (square meters):
area = width * height 
# Use lawnPrice and calculate the lawn cost:
llawnPrice = area * 2

Maybe use different variables like lawnCost to differentiate them in your code.

2 Likes

Thanks I beat it :grin:

1 Like

You’re welcome!! congrats!!

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.