So I fixed the original problem (I think) but now I have a new problem. *super sigh* Suggestions? Its just not been a good programming day for me.
Now it gets up to the "Total tiles required is " Part and then goes back to Enter size of tile in inches. It doesn't count down the room number and stop when room > 0. I tried both RoomNumb--; and RoomNumb = RoomNumb - 1; It gets to line 28 then starts back at line 18...
Code:
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
//Function prototypes
void GetRoomNumb (int& RoomNumb);
void GetRoomTiles (int& RoomTiles);
void GetBoxAmt (int& BoxAmt, int& Remainder);
int main()
{
//Variable Declarations
int RoomNumb, RoomTiles, TileInches;
int BoxAmt, Remainder;
int RoomTiles2 = 0;
GetRoomNumb(RoomNumb);
while (RoomNumb > 0)
{
GetRoomTiles(RoomTiles);
std :: cout << "Room requires " << RoomTiles << " tiles." << endl;
RoomTiles2 = RoomTiles2 + RoomTiles;
RoomNumb = RoomNumb - 1;
}
std :: cout << "Total tiles required is " << RoomTiles2 << ".";
GetBoxAmt(BoxAmt, Remainder);
std :: cout << "Total tiles required is " << RoomTiles << "." << endl
<< "Number of boxes needed is " << BoxAmt << "." << endl
<< "There will be " << Remainder << " extra tiles." << endl;
system("Pause");
return 0;
}
//**********************************************************************************************************
void GetRoomNumb (int& RoomNumb)
{
std :: cout << "Enter number of rooms: ";
std :: cin >> RoomNumb;
}
//**********************************************************************************************************
void GetBoxAmt (int& BoxAmt, int& Remainder)
{
int RoomTiles;
GetRoomTiles(RoomTiles);
BoxAmt = RoomTiles / 20;
Remainder = BoxAmt % 20;
if (Remainder = 0)
{
BoxAmt = BoxAmt;
Remainder = 0;
}
else
{
BoxAmt = BoxAmt + 1;
Remainder = BoxAmt % 20;
}
}
//**********************************************************************************************************
void GetRoomTiles (int& RoomTiles)
{
//Variable Declarations
int WidthFeet, WidthInches, TotalWidthInches, WidthTiles, WidthTile2;
int LengthFeet, LengthInches, TotalLengthInches, LengthTiles, LengthTile2;
int Remainder, TileInches;
int Corner;
//Get Values
std :: cout << "Enter size of tile in inches: ";
std :: cin >> TileInches;
std :: cout << endl << "Enter room width (feet and inches, separated by a space): ";
std :: cin >> WidthFeet >> WidthInches;
std :: cout << endl << "Enter room length (feet and inches, separated by a space): ";
std :: cin >> LengthFeet >> LengthInches;
//Calculate Width
TotalWidthInches = WidthFeet * 12 + WidthInches;
WidthTiles = TotalWidthInches / TileInches;
Remainder = TotalWidthInches % TileInches;
Corner = 0;
if (Remainder = 0)
{
WidthTile2 = 0;
Corner++;
}
else
{
WidthTile2 = WidthTiles;
Corner = 1;
}
//Calculate Length
TotalLengthInches = LengthFeet * 12 + LengthInches;
LengthTiles = TotalLengthInches / TileInches;
Remainder = TotalLengthInches % TileInches;
if (Remainder = 0)
{
LengthTile2 = 0;
Corner = Corner + 0;
}
else
{
LengthTile2 = LengthTiles;
Corner = 1;
}
//Calculate Total Tiles
RoomTiles = (WidthTiles * LengthTiles) + (WidthTile2 + LengthTile2) + Corner;
}