Hey there! Sign in to join this conversationNew here? Join for free

Python calculating surface area of walls, HELP! What is wrong with my code? watch

    • Thread Starter
    Offline

    5
    ReputationRep:
    *What is wrong with my code? It only calculates the surface area for one of the walls and not the others, what am I doing wrong!? Please help ASAP
    print("Welcome to the estimation menu!")
    global total
    global NumberOfRooms
    global NumberOfWalls
    global SurfaceArea

    CustomerNumber = input("What is your customer number?: ")
    DateOfEstimation = input("What is your date of estimation?: ")

    def estimation():
    NumberOfRooms = 0
    counter = 0
    total = 0
    NumberOfWalls = 0
    SurfaceArea = 0
    height = 0
    width = 0
    TotalHeightOfWalls = 0
    TotalWidthOfWalls = 0

    NumberOfRooms = int(input("How many rooms would you like painted?: "))
    counter = int(NumberOfRooms) + int(counter)
    while int(counter)>0:
    name = input("What is the name of the room you would like painted? For example, dining, lounge, bedroom etc. : ")
    wallpaper_removed = input("Do you want the wall paper to be removed? Type 'Yes' or 'No': ")
    if wallpaper_removed == "Yes":
    total = int(total) + 70
    numberofwalls = int(input("Please enter the number of walls you would like painted for this room: "))
    while int(numberofwalls) > 0:
    height = int(input("What is the height of the wall? (In Meters): "))
    width = int(input("What is the width of the wall? (In Meters): "))
    numberofwalls = int(numberofwalls) - 1
    counter = int(counter)-1
    TotalHeightOfWalls = int(TotalHeightOfWalls + height)
    TotalWidthOfWalls = int(TotalWidthOfWalls + width)
    SufaceArea = (TotalWidthOfWalls * TotalHeightOfWalls)
    print("Total Surface Area of walls =",SufaceArea)
    estimation()
    #You just need to ask for the height and width, then add it to the total
    Offline

    0
    ReputationRep:
    Everything on line 2 is written
    • Thread Starter
    Offline

    5
    ReputationRep:
    (Original post by luis2201)
    Everything on line 2 is written
    What do you mean?
    Offline

    20
    You could try using the 'else / elseif' function :dontknow:

    It might also be due to the fact that you haven't integrated 'global total' in the second line at the end.
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?
Useful resources

Study tools

Rosette

Essay expert

Learn to write like a pro with our ultimate essay guide.

Thinking about uni already?

Thinking about uni already?

See where you can apply with our uni match tool

Student chat

Ask a question

Chat to other GCSE students and get your study questions answered.

Creating

Make study resources

Create all the resources you need to get the grades.

Planner

Create your own Study Plan

Organise all your homework and exams so you never miss another deadline.

Resources by subject

From flashcards to mind maps; there's everything you need for all of your GCSE subjects.

Papers

Find past papers

100s of GCSE past papers for all your subjects at your fingertips.

Help out other students

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.