Python Forum

Full Version: Count how many carpets you need to fill room floor without multiplication/division
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I've got this task to coplete. I must do it using While:
Room length is A meters and with is B. How many square carpets, which have an edge of C meters, do you need to fully fill a room? You can't use multiplication or division.

a=float(input('What is the length of the room? '))
b=float(input('What is the width of the room? '))
c=float(input('What is the length of square carpet edge? '))
i=0
while a >= c:
    a = a - c
    i = i + 1
print(i)
I could only manage to count one column of carpets and whey won't fill the floor completely if the length was a float number.
First, do it with while a > 0:. That will cover the fractional portion. That assumes the carpets are meant to be kept whole, and therefore overlap to cover fractional spaces. I think that is necessary to the problem, but you should clarify that with your teacher.

Then, do another while loop where you subtract c from b. Instead of adding one, and the number of carpets to fill the length of the room.