130k views
0 votes
A room has one door, two windows, and a built-in bookshelf and it needs to be painted. Suppose that one gallon of paint can paint 120 square feet. Write a program that prompts the user to input the length and width (in feet) of: The door Each window The bookshelf And the length, width, and height of the room. The program outputs: The amount of paint needed to paint the walls of the room.

User Stas BZ
by
5.2k points

1 Answer

9 votes

Answer:

In Python:

doorLength = float(input("Door Length: "))

doorWidth = float(input("Door Width: "))

windowLength1 = float(input("Window 1 Length: "))

windowWidth1 = float(input("Window 1 Width: "))

windowLength2 = float(input("Window 2 Length: "))

windowWidth2 = float(input("Window 2 Width: "))

shelfLength = float(input("Bookshelf Length: "))

shelfWidth = float(input("Bookshelf Width: "))

totalarea = doorLength * doorWidth + windowLength1 * windowWidth1 + windowLength2 * windowWidth2 + shelfLength*shelfWidth

gallons = totalarea/120

print("Gallons: "+str(gallons))

Step-by-step explanation:

The next two lines get the dimension of the door

doorLength = float(input("Door Length: "))

doorWidth = float(input("Door Width: "))

The next two lines get the dimension of the first window

windowLength1 = float(input("Window 1 Length: "))

windowWidth1 = float(input("Window 1 Width: "))

The next two lines get the dimension of the second window

windowLength2 = float(input("Window 2 Length: "))

windowWidth2 = float(input("Window 2 Width: "))

The next two lines get the dimension of the shelf

shelfLength = float(input("Bookshelf Length: "))

shelfWidth = float(input("Bookshelf Width: "))

This calculates the total area of the door, windows and bookshelf

totalarea = doorLength * doorWidth + windowLength1 * windowWidth1 + windowLength2 * windowWidth2 + shelfLength*shelfWidth

This calculates the number of gallons needed

gallons = totalarea/120

This prints the number of gallons

print("Gallons: "+str(gallons))

User JKMajcen
by
4.6k points