I need some help,Here is the problem, I work for a company that lays ceramic floor tile and I need a program that estimates the number of boxes of tile for a job. A job is estimated by taking the dimensions of each room in feet and inches, and converting these dimensions into multiple of the tile size(round up any partial multiple) before multipylying to get the number of tiles for the room. A box contains 20 tiles, so the total number needed should be divided by 20 and round up to get the number of boxes. the tiles are assumed to be square. The program should initially prompt the user for the size of the tiles in inches, and the number of rooms to be input. It should then input the dimensions for each room, and output the tiles needed for that room. After the last room is input, the program also should output the total number of tiles needed, the number of boxes needed, and how many extra tiles will be left over.
Gives all the numbers the book asks ]for although I didn’t use any functions. It also needs a way to check for invalid inputs like 13 for inches and number of rooms < 0. I’ll keep working on it. Didn’t you get some code from that programming website? Send me what you got, maybe it’ll give me some ideas.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int tileSize;
int numOfRooms;
int roomWidIn;
int roomWidFt;
int roomLenIn;
int roomLenFt;
int lenTot;
int widTot;
int tilesPerRm = 0;
int totalTiles = 0;
int numOfBoxes = 0;
int a;
cout << "Enter number of rooms: ";
cin >> numOfRooms;
cout << "Enter size of tile in inches: ";
cin >> tileSize;
while (numOfRooms > 0)
{
cout << "Enter room width (feet and inches, separated by a space): ";
cin >> roomWidFt >> roomWidIn;
cout << "Enter room length (feet and inches, separted by a space): ";
cin >> roomLenFt >> roomLenIn;
widTot = ((roomWidFt*12+roomWidIn)/tileSize);
if (((roomWidFt*12+roomWidIn)%tileSize) != 0) ++widTot;
lenTot = ((roomLenFt*12+roomLenIn)/tileSize);
if (((roomLenFt*12+roomLenIn)%tileSize) != 0) ++lenTot;
cout << "Room requires " << (widTot * lenTot) << " tiles." << endl;
totalTiles = totalTiles + (widTot * lenTot);
numOfRooms = numOfRooms - 1;
}
cout << "Total Tiles required is " << totalTiles << "." << endl;
numOfBoxes = totalTiles/20;
if ((totalTiles%20) != 0) ++numOfBoxes;
cout << "Number of boxes needed is " << numOfBoxes << "." << endl;
cout << "There will be " << (numOfBoxes*20) - totalTiles << " extra tiles." << endl;
cin >> a;
return 0;
}