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
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
// Function prototypes
void GetRoomNumber (int NumberOfRooms);
void GetRest (int SizeOfTile, int WidthFeet, int WidthInches, int LengthFeet, int LengthInches);
void DetermineTiles (int TilesForRoom);
void DetermineBoxes (int BoxesForRoom);
void PrintResults (int TilesTotal, int BoxesTotal, int Leftovers);
int main()
{
//Variable declarations
int NumberOfRooms,SizeOfTile;
int WidthFeet, WidthInches;
int LengthFeet,LengthInches;
int TilesForRoom, BoxesForRoom, TilesTotal, BoxesTotal, Leftovers;
GetRoomNumber (NumberOfRooms);
while (NumberOfRooms > 0)
{
GetRest (SizeOfTile, WidthFeet, WidthInches, LengthFeet, LengthInches);
DetermineTiles (TilesForRoom);
DetermineBoxes (BoxesForRoom);
BoxesTotal += BoxesForRoom;
cout << "Room requires = " << BoxesTotal << " boxes." << endl; //Displaying required boxes for the room
}
Leftovers = (BoxesTotal * TilesTotal) - TilesTotal; //Calculation leftover tiles
//Here calling PrintResults function to display the results
PrintResults (TilesTotal, BoxesTotal, Leftovers);
system ("pause");
return 0;
} // end of main function
//**************************************************
//This Function Prompt User to enter number of rooms
void GetRoomNumber (int NumberOfRooms)
{
cout << "Enter number of rooms: " << endl;
cin >> NumberOfRooms;
}
//**************************************************
//This Function Prompt User to enter the rest of information needed
void GetRest (int SizeOfTile, int WidthFeet, int WidthInches, int LengthFeet, int LengthInches)
{
cout << "Enter size of tile in inches that is to be used: " << endl;
cin >> SizeOfTile;
cout << "Enter room width (feet and inches, separated by a space): " << endl;
cin >> WidthFeet >> WidthInches;
cout << "Enter room length (feet and inches, separated by a space): " << endl;
cin >> LengthFeet >> LengthInches;
}
//**************************************************
//This Function calculates the number of tiles required for each room.
void DetermineTiles (int TilesForRoom, int SizeOfTile, int WidthFeet, int WidthInches, int LengthFeet, int LengthInches)
{
TilesForRoom = ((WidthFeet * 12) + WidthInches) / float(SizeOfTile) * ((LengthFeet * 12) + LengthInches) / float(SizeOfTile);
}
//*******************************************************
//This Function calculates the number of boxes needed for each room.
void DetermineBoxes (int BoxesForRoom, int TilesForRoom)
{
BoxesForRoom = TilesForRoom / 20;
}
//****************************************************
//This Function displays the calculated results for a job: Total number of tiles, Boxes and Leftovers.
void PrintResults (int TilesTotal, int BoxesTotal, int Leftovers)
{
cout << "Total tiles required for a job: " << TilesTotal << " . " << endl;
cout << "Total boxes required for a job: " << BoxesTotal << " . " << endl;
cout << "Total leftovers not used for a job: " << Leftovers << " . " << endl;
}
|