1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#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 << "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;
}
|