Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The floor of a room is to be covered with tiles of dimension 15 cm square (e.g.

ID: 3623143 • Letter: T

Question

The floor of a room is to be covered with tiles of dimension 15 cm square (e.g. 15 cm on each side). There is to be a gap of 2 mm between tiles when laid. Write a program that, given the room dimensions (in meters), works out the number of whole tiles required.

Additional criteria for this program:
1. No calculations should be performed within any printf statement.
2. DO NOT make ANY calculations by hand and insert the answers into the program – all calculations, including conversions must be performed within the program.
3. Use the pow(x,y) command to calculate the area of a tile. The pow(x,y) command requires the math.h library!

Explanation / Answer

//Header file section

#include<math.h>

#include<iostream>

using namespace std;

void main()

{

int tile_dimen=15;

int gap=2;

double length_Room,width_Room,total_tiles;

//inputting length of room

cout<<"Enter length of room:";

cin>>length_Room;

length_Room=length_Room*100;

//inputting width of room

cout<<"Enter width of room:";

cin>>width_Room;

width_Room=width_Room*100;

//calculating

total_tiles=(length_Room*width_Room)/(pow((tile_dimen+gap),2));

cout<<"Total tiles for Room is:"<<total_tiles<<endl;

//pause system for a while

system("pause");

}//end main