Mr. FOUARD assignment 2

 Calculating Tiles for a Rectangular Shape

1. Flow Chart (visual steps)

1. *Start*

2. Input *length* and *width* of rectangle.

3. Input *tile_length* and *tile_width*.

4. Calculate area of rectangle: `area = length * width`.

5. Calculate area of one tile: `tile_area = tile_length * tile_width`.

6. Calculate number of tiles: `tiles = area / tile_area`.

7. Output *tiles* needed.

8. *End*.


2. Pseudocode

BEGIN

  INPUT length, width  // rectangle dimensions

  INPUT tile_length, tile_width  // tile dimensions

  area ← length * width

  tile_area ← tile_length * tile_width

  tiles ← area / tile_area

  OUTPUT tiles

END


3. Code (Python example)

def calculate_tiles(length, width, tile_length, tile_width):

    # Calculate areas

    area = length * width

    tile_area = tile_length * tile_width

    

    # Calculate number of tiles (round up if partial tiles needed)

    tiles = area / tile_area

    return int(tiles) if tiles.is_integer() else int(tiles) + 1


Get inputs

length = float(input("Enter rectangle length: "))

width = float(input("Enter rectangle width: "))

tile_length = float(input("Enter tile length: "))

tile_width = float(input("Enter tile width: "))


Output result

tiles_needed = calculate_tiles(length, width, tile_length, tile_width)

print(f"Tiles needed: {tiles_needed}")

Comments

Popular posts from this blog

Mr. Fuad Assignment