Need some help - stuck!!!

Hi guys!
Trying to build a program for my assignment:

Program needs to estimate the number of boxes of tile for a job. A job is estimated by taking dimensions of the room in feet and inches and converting those dimensions into a multiple of the tile size (rounding any partial multiple) before multiplying to get the number of tiles for the room. A box contains 20 tiles (so total number needs to be divided by 20 and round up). After data for the last room is input, the program should output the total number of tiles needed, the number of boxes of tiles needed, and how many extra tiles will be leftover.
I am also required to use functional decomposition to solve this problem.. And my program should check for invalid data input (such as non positive dimensions, number of rooms less than 1, number of inches greater than 11, and so on). Also need to prompt the user for correct input.

Here what I came up with, but it is not running.
Thank you! Really stuck =(

//***************************************************
//This Program 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.
//Each Box contains 20 tiles which assumed to be square.
//**********************************************

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;
}
Last edited on
Do you know the difference between pass by value and pass by reference?

Line 52: In GetRoomNumber(), NumberOfRooms is passed by value. This means you are operating on a local copy of the variable. Any changes to the local value (i.e. cin) are lost when the function exits.

Line 62: GetRest(), all values are lost on exit.

Line 79: DetermineTiles(), TilesForRoom is lost on exit.

Line 90: DetermineBoxes(), BoxesForRoom is lost on exit.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.


Last edited on
Thank you for your time!
I formatted my post so it is easier to read and answer.
We've just started to learn about pass by value and pass by reference. I assume I need to change my variables to reference variables ( by using the ‘&’ symbol).
I maybe wrong.
I am new at C++ and programming in general (coming from accounting background). Trying to conquer a new field is a little hard especially being a single mom to a newborn (not blaming to a post-prego brain ;) ). Therefore any comment are GREATLY appreciated!
Thanks again!
Topic archived. No new replies allowed.