Create a program to estimate the number of boxes of tile tha
Solution
#include<iostream>
#include<cmath>
#define MAX 10
using namespace std;
int main()
{
int feet, inches,no_rooms, size_tile_inches, no_tiles_box, count = 0,no_of_boxes ;
int area_room[MAX];
double tiles_required_per_room[MAX];
int total_tiles = 0;
cout << \"Enter the number of rooms: \";
cin >> no_rooms;
cout << \"Enter number of tiles in a box: \";
cin >> no_tiles_box;
cout << \"Enter the size of tile in inches: \";
cin >> size_tile_inches;
while(count < no_rooms)
{
cout << \"\ Length and width of room no\"<<count+1<<\" in feet and inches separated by space: \";
cin >> feet >> inches;
if (inches > 12)
{
cout << \"Inches cannot be greater than 12 , please try again\";
continue;
}
if (inches < 0 || feet < 0)
{
cout << \"Feet or inches cannot be negetive, please try again\" << endl;
continue;
}
//calculate area of each room
area_room[count] = feet * 12 + inches;
/*tiles required can be calculated as area of the room divided by area of square tile, here length and breadth given in feet and inches ,
*so convert it to lower conversion ie everything ti incges by multiplying feet with 12*/
tiles_required_per_room[count] = ceil(area_room[count] / (size_tile_inches*size_tile_inches));
cout << \"Number of tiles required for room\" << count + 1 << \" : \";
cout << tiles_required_per_room[count];
total_tiles += tiles_required_per_room[count];
count++;
}
cout << \"\ No of boxes required are : \";
//no of boxes can be calculated as follows: dividing total_tiles by no of tiles in boxes
no_of_boxes = total_tiles / no_tiles_box;
int rem = total_tiles % no_tiles_box;
if (rem == 0 )
{
cout << no_of_boxes ;
}
else
{
cout << no_of_boxes+1<< \" and remaining tiles in boxes are : \" << no_tiles_box - rem << endl;
}
}
------------------------------------------------------------------------------------------------------------------------
//output
Enter the number of rooms: 3
Enter number of tiles in a box: 10
Enter the size of tile in inches: 8
Length and width of room no1 in feet and inches separated by space: 12 10
Number of tiles required for room1 : 2
Length and width of room no2 in feet and inches separated by space: 14 15
Inches cannot be greater than 12 , please try again
Length and width of room no2 in feet and inches separated by space: 14 12
Number of tiles required for room2 : 2
Length and width of room no3 in feet and inches separated by space: 13 9
Number of tiles required for room3 : 2
No of boxes required are : 1 and remaining tiles in boxes are : 4

