My name is Leonard Norwood Jr.

If anyone knows a program that will estimate the number of boxes of tile needed for a job. A job is estimated by taking the dimensions of each room in feet and inches and converting these into a multiple of the tile size (rounding up any partial multiple) before multiplying to get the number of tiles for the room. A box should have 20 tiles, so I need to divide the total number needed by 20 and rounded up to get the number of boxes (they are square). Here is what I have so far:

``````#include <iostream>
using namespace std;

int TilesPerRoom(int roomWF, int roomWI, int Tsize,int &roomW,int &roomWR, int &RroomW, int roomLF, int roomLI, int &roomL, int &roomLR, int &RroomL, int &TilesR);
void TotalBox(int Ttiles, int &Tbox, int &TboxR);
int roomWF;
int roomWI;
int roomLF;
int roomLI;
int Tsize;
int TilesR;
int roomW;
int roomWR;
int RroomW;
int roomL;
int roomLR;
int RroomL;
int Trooms;
int Tbox;
int TboxR;
int Ttiles = 0;
int main()
{

while(Trooms < 1)
{
cout << "Enter the number of rooms tiles are needed:";
cin >> Trooms;
if (Trooms < 1)

cout << "Please re-enter a positive value of 1 or greater." << endl;
}

while (Trooms >= 1)
{
Tsize = -1;
while (Tsize <= 0)
{
cout << "Enter the size of tile, in inches.";
cin >> Tsize;

if (Tsize <= 0)
cout << "Please re-enter the positive value greater than 0." << endl;
}
roomWF = -1;
roomWI = -1;
while ((roomWF <= 0) && (roomWI <= 0))
{
cout << "Enter room width (feet and inches, separated by a space):";
cin >> roomWF >> roomWI;
if (((roomWF <= 0) && (roomWI <= 0)))
cout << "Please re-enter positive values greater than 0." << endl;
}
roomLF = -1;
roomLI = -1;
while ((roomLF <= 0) && (roomLI <= 0))
{
cout << "Enter room length (in feet and inches, separated by space):";
cin >> roomLF >> roomLI;

if ((roomLF <= 0) && (roomLI <= 0))
cout << "Please re-enter positive values greater than 0." << endl;
}

cout << " This room requires " << TilesR << " tiles" << endl;
Trooms--;

Ttiles = TilesR + Ttiles;
}

cout << "The total amount of tiles required for the rooms(s) is " << Ttiles << endl;

TotalBox(Ttiles, Tbox, TboxR);
cout << "You will need " << Tbox << "boxes for the job." << endl;
cout << "There will be " << TboxR << "extra tiles." << endl;

char exit_char;
cout <<"\nPress any key and <enter> to exit\n";
cin >> exit_char;

system("pause");
return 0;

}

int TilesPerRoom(int roomWF, int roomWI, int Tsize,int &roomW,int &roomWR, int &RroomW, int roomLF, int roomLI, int &roomL, int &roomLR, int &RroomL, int &TilesR)
{
roomW = ((roomWF * 12) + roomWI);
roomWR = roomW % Tsize;
RroomW = roomW / Tsize;

{
if (roomWR != 0)
RroomW++;
}

roomL = ((roomLF * 12) + roomLI);
roomLR = roomL % Tsize;
RroomL = roomL / Tsize;

{
if (roomLR != 0)
RroomL++;
}

roomW = RroomW * Tsize;
roomL = RroomL * Tsize;

TilesR = ((roomW * roomL)/(Tsize * Tsize));

return TilesR;
}

void TotalBox(int Ttiles, int &Tbox, int &TboxR)
{
TboxR = (Ttiles % 20);
Tbox = (Ttiles / 20);
{
if (TboxR != 0)
Tbox++;
}

}``````

And it is certainly supposed to run like this.

Enter number of rooms : 2
Enter size of tile in inches: 12
Enter room width (feet and inches, separated by a space); 17 4
Enter room length (same as above): 9 3
Room requires 180 tiles

Enter room width (same as above): 11 6
Enter room length (same as above) 11 9
Room requires 144 tiles
Total titles required is 324
Number of boxes needed is 17.
There will be 16 extra tiles.

This program is only done with functions only, I haven't even learned enum, struct, or all that stuff yet. I'm still not getting it right and I already have the calculations right there, but somethings off.

``int get_tiles(int& length, int& width){return length * width}``

couldn't you just get the input of the area of the room and the tiles, then calculate how many tiles are needed.

``````//sample
int rooml, roomw, tilel, tilew, tilecount, tileneed; //normally you would place multiple ints
on the same line to save space.

int arear,areat;

int return_ammount()
{
arear = rooml * roomw;
areat = tilel * tilet;

tileneed = arear / areat

return tileneed;
}

int main()
{
cout << "Enter number of tiles: ";
cin >> tilecount;

cout << "/nEnter room length: ";
cin >> rooml;

cout << "/nEnter room width: ";
cin >> roomw;

cout << "/nEnter tile length: ";
cin >> tilel;

cout << "/nEnter tile width: ";
cun >> tilew;

cout << "/n/nTotal Tiles Needed: " << return_amout();
cout << "/nTiles Left: " << tileneed - tilecount;

return 0;
}``````

although my c+++ is a bit rusty. haven't programmed in it for a while.

That can't be all.

Look I know I get the value parameters and reference parameters, in fact, I did do a little program once with the addition and multiply one. And when I finished with this, it did compile, seeing as all the value/ref parameters were right with each value and argument in the right place. And I already have calculation

(10 * 12) + 2) = 122
122 / 12 = 10.16666667

Stuff like that is already on the program...The problem might be I either have too many ints, and there's something causing the input of size tile to appear again when it wasn't supposed too. I did go too far and causing something complicated even though it compiled just fine....

couldn't you just get the input of the area of the room and the tiles, then calculate how many tiles are needed.

``````//sample
int rooml, roomw, tilel, tilew, tilecount, tileneed; //normally you would place multiple ints
on the same line to save space.

int arear,areat;

int return_ammount()
{
arear = rooml * roomw;
areat = tilel * tilet;

tileneed = arear / areat

return tileneed;
}

int main()
{
cout << "Enter number of tiles: ";
cin >> tilecount;

cout << "/nEnter room length: ";
cin >> rooml;

cout << "/nEnter room width: ";
cin >> roomw;

cout << "/nEnter tile length: ";
cin >> tilel;

cout << "/nEnter tile width: ";
cun >> tilew;

cout << "/n/nTotal Tiles Needed: " << return_amout();
cout << "/nTiles Left: " << tileneed - tilecount;

return 0;
}``````

although my c+++ is a bit rusty. haven't programmed in it for a while.

Not like that. I'm pretty sure it's supposed to use the dimensions and convert them into a multiple of tile size.

``````#include <iostream>
using namespace std;

int TilesPerRoom(int roomWF, int roomWI, int Tsize,int &roomW,int &roomWR, int &RroomW, int roomLF, int roomLI, int &roomL, int &roomLR, int &RroomL, int &TilesR);
void TotalBox(int Ttiles, int &Tbox, int &TboxR);
int roomWF, roomWI, roomLF, roomLI, Tsize, TilesR;
int roomW, roomL, roomWR, RroomW, roomLR, RroomL, Trooms;
int Tbox, TboxR, Ttiles = 0;
int main()
{

while(Trooms < 1)
{
cout << "Enter the number of rooms tiles are needed:";
cin >> Trooms;
if (Trooms < 1)

cout << "Please re-enter a positive value of 1 or greater." << endl;
}

while (Trooms >= 11)
{
Tsize = -1;
while (Tsize <= 0)
{
cout << "Enter the size of tile, in inches.";
cin >> Tsize;

if (Tsize <= 0)
cout << "Please re-enter the positive value greater than 0." << endl;
}
roomWF = -1;
roomWI = -1;
while ((roomWF <= 0) && (roomWI <= 0))
{
cout << "Enter room width (feet and inches, separated by a space):";
cin >> roomWF >> roomWI;
if (((roomWF <= 0) && (roomWI <= 0)))
cout << "Please re-enter positive values greater than 0." << endl;
}
roomLF = -1;
roomLI = -1;
while ((roomLF <= 0) && (roomLI <= 0))
{
cout << "Enter room length (in feet and inches, separated by space):";
cin >> roomLF >> roomLI;

if ((roomLF <= 0) && (roomLI <= 0))
cout << "Please re-enter positive values greater than 0." << endl;
}

cout << " This room requires " << TilesR << " tiles" << endl;
Trooms--;

Ttiles = TilesR + Ttiles;
}
TilesPerRoom(roomWF, roomWI, Tsize, roomW, roomWR, RroomW, roomLF, roomLI, roomL, roomLR, RroomL ,TilesR);
cout << "The total amount of tiles required for the rooms(s) is " << Ttiles << endl;

TotalBox(Ttiles, Tbox, TboxR);
cout << "You will need " << Tbox << "boxes for the job." << endl;
cout << "There will be " << TboxR << "extra tiles." << endl;

char exit_char;
cout <<"\nPress any key and <enter> to exit\n";
cin >> exit_char;

system("pause");
return 0;

}

int TilesPerRoom(int roomWF, int roomWI, int Tsize,int &roomW,int &roomWR, int &RroomW, int roomLF, int roomLI, int &roomL, int &roomLR, int &RroomL, int &TilesR)
{
roomW = ((roomWF * 12) + roomWI);
roomWR = roomW % Tsize;
RroomW = roomW / Tsize;

{
if (roomWR != 0)
RroomW++;
}

roomL = ((roomLF * 12) + roomLI);
roomLR = roomL % Tsize;
RroomL = roomL / Tsize;

{
if (roomLR != 0)
RroomL++;
}

roomW = RroomW * Tsize;
roomL = RroomL * Tsize;

TilesR = ((roomW * roomL)/(Tsize * Tsize));

return TilesR;
}

void TotalBox(int Ttiles, int &Tbox, int &TboxR)
{
TboxR = (Ttiles % 20);
Tbox = (Ttiles / 20);
{
if (TboxR != 0)
Tbox++;
}

}``````

So I saved some lines, but still, that doesn't solve this little problem of mine. So, I'm gonna think over this while playing a game. I'm just glad that for this complicated program is at least complied and the Ref/value parameters are as it supposed to be...

Not like that. I'm pretty sure it's supposed to use the dimensions and convert them into a multiple of tile size.

well, i got from the question that the user(s) need to calculate how many tiles are needed for a room. my program does that. that was my interpretation of the problem.

``````#include <iostream>
using namespace std;

void GetRoomTiles(int WidthFeet, int WidthInches, int &TotalWidth, int LengthFeet, int LengthInches, int &TotalLength, int TileSize, int &RoomTiles);
void GetTotalTiles(int RoomTiles, int &TotalTiles);
void GetNumberOfBoxes(int TotalTiles, int TileBoxes, int &ExtraTiles, int &NumberOfBoxes);

int main()
{
int NumberOfRooms;
int TileSize;
int WidthFeet, WidthInches, TotalWidth;
int LengthFeet, LengthInches, TotalLength;
int RoomTiles, TotalTiles;
int NumberOfBoxes = 0;
int TilesBoxes = 20;
int ExtraTiles = 0;
ExtraTiles++;

while (NumberOfRooms < 1)
{
cout << "Enter the number of rooms needed for tiles:";
cin >> NumberOfRooms;

if (NumberOfRooms < 1)
cout <<"Please re-enter a positive value greater than 0." << endl;
}

while(NumberOfRooms >= 11)
{
TileSize = -1;
while (TileSize <= 0)

cout <<"Enter the size of tile in inches.";
cin >> TileSize;

if (TileSize <= 0)
cout << "Please re-enter the positive value greater than 0." << endl;

if (TileSize <= 11)
cout << "Make sure to enter inches greater than 11." << endl;
}
WidthFeet = -1;
WidthInches = -1;

while((WidthFeet <= 0) && (WidthInches <= 0))
{
cout << "Enter room width (feets and inches, separated by space)" << endl;
cin >> WidthFeet >> WidthInches;
if((WidthFeet <= 0) && (WidthInches <= 0))
cout << "Please re-enter positive values dimensions greater than 0." << endl;
}
LengthFeet = -1;
LengthInches = -1;

while((LengthFeet <= 0) && (LengthInches <= 0))
{
cout << "Enter room length (feets and inches, separated by space)" << endl;
cin >> LengthFeet >> LengthInches;
if((LengthFeet <= 0) && (LengthInches <= 0))
cout << "Please re-enter positive values dimensions greater than 0." << endl;

GetRoomTiles(WidthFeet, WidthInches, TotalWidth, LengthFeet, LengthInches, TotalLength, TileSize, RoomTiles);
GetTotalTiles(RoomTiles, TotalTiles);
}

GetNumberOfBoxes(TotalTiles, TilesBoxes, ExtraTiles, NumberOfBoxes);

system("pause");
return 0;
}

void GetRoomTiles(int WidthFeet, int WidthInches, int &TotalWidth, int LengthFeet, int LengthInches, int &TotalLength, int TileSize, int &RoomTiles)
{
TotalWidth = ((WidthFeet * 12) + WidthInches);
cout << "Total Width in inches is " << TotalWidth << endl;
TotalLength = ((LengthFeet * 12) + LengthInches);
cout << "Total Length in inches is " << TotalLength << endl;

RoomTiles = ((TotalWidth / (TileSize - 1)) * (TotalLength / (TileSize - 1)));
cout << "The room requires: " << RoomTiles << " tiles." << endl;
}
void GetTotalTiles(int RoomTiles, int &TotalTiles)
{
TotalTiles += RoomTiles;
cout << "Total tiles required: " << TotalTiles << endl;
}
void GetNumberOfBoxes(int TotalTiles, int TilesBoxes, int &ExtraTiles, int &NumberOfBoxes)
{
ExtraTiles = TotalTiles / TilesBoxes;
NumberOfBoxes = ((TotalTiles + ExtraTiles) / TilesBoxes);
cout << "The total number of boxes needed is: " << NumberOfBoxes << endl;
cout << "There will be " << ExtraTiles << " extra tiles." << endl;
}``````

Okay I changed the program a bit so the calculations itself on the botton should be A-OK, however, I still have a problem with inputting invalid data inputs from the looks of it in one of the loops. Once again, it complies fine, but the program doesn't work much. I'm doing something wrong with the loops somewhere..Sorry it took me awhile though.

And in order to elaborate the program I'm doing, it should be familiar to some of you...

Need to estimate 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 a multiple of the tile size (rounding up any partial multiple) before multiplying 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 rounded up to get the number of boxes. The tiles are assumed to be square.

Program should prompt user for size of the tile in inches and the number of rooms to be covered with tile. It should then input the dimensions for each room and output the number of tiles needed for that room. After data for the last room is input the program should output the total number of tiles needed, the number of boxes of tile needed and how many extra tiles will be left over.

Use functional decomposition to solve this problem and code the solution using functions wherever it makes sense to do so. Your program should check for invalid data such as non-positive dimensions, number of rooms less than one, number of inches greater than 11, and so on. It should prompt the user for corrected input whenever it detects invalid input. Now that your programs are becoming more complex it is even more important for you to use proper indentation and style, meaningful identifiers and appropriate comments.

I'm still waiting here...No one's replied so far, and I need a solution or a clue....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.