Sequential Exercise 5

Required, a program that will calculate the number of packs and cost of the tiles required to cover the non-shaded area.

Algorithm

TileCalculation
    centimetres to metres:= 10000
    number in pack:= 15

    read room length
    read room width
    read shaded length
    read shaded width
    area to tile:= room length * room width - shaded length * shaded width


    read tile side
    area of tile:= tile side* tile side/centimetres to metres {convert tile area to sq mtres}
    tiles required:= area to tile/area of tile {rounded up}


    packs required:= tiles required/number in pack {rounded up}

    read cost per pack {leave generic}
    cost of tiles:= packs required*cost per pack

    write number of packs
    write cost of tiles
End.

 

Data Item Table

Data Item Program name Size/Type Range
Centimetres to metres CMS_TO_METRES 10000
Room length roomLength float
Room width roomWidth float
Shaded length shadedLength float
Shaded width shadedWidth float
Area to tile areaToTile float
Tile side tileSide float
Area of tile areaToTile float
Tiles required tilesRequired double
Number in pack NUM_IN_PACK 15
Packs required packsRequired double
Cost per pack costPerPack float
Cost of tiles costOfTiles float


PROGRAM: tiles.cpp