So close but seriously stuck.

Okay so I've been working on this program for a few days witch is weird for me. Working on one for more than a day is weird for me but this one is a pain in my side. I'm to the point where I almost have it finished but yet not.
So when I run it it goes through the
while (RoomNumb > 0)
statement and the first cout section after that
std :: cout << "Total tiles required is << RoomTiles2 << ".";
but never goes past the GetBoxAmt section. It just skips it and continues back to the while statement and cycles through it. I've tried both
1
2
RoomNumb = RoomNumb - 1; 
RoomNumb--; 

but neither fixes the problem. Any suggestions?

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; 
}
1
2
3
4
5
	if (Remainder = 0)
	{
		BoxAmt = BoxAmt; 
		Remainder = 0; 
	}

Doesn't make much sense.
a) You're setting remainder to 0 ('=' is assignment, not comparison), so it is always true.
b) If Remainder == 0 -> set boxAmt to itself and remainder to 0, or in other words: do nothing. Why is it there?
So I can't believe I didn't see that but I changed it to

1
2
3
4
5
if (Remainder != 0)
	{
		BoxAmt = BoxAmt + 1; 
		Remainder = BoxAmt / 20; 
	}

That works right?

But it still doesn't get to the part where it prints the boxes needed and the extra.
I would suspect the problem is that you're calling GetRoomTiles in your GetBoxAmt function, you're trying to calculate how many boxes you would need for all the tiles in all the rooms right? So why not just pass the RoomTiles2 variable to GetBoxAmt function
Okay, I got it to work. Thank you!
Topic archived. No new replies allowed.