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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.