Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
Handling Random
rand() returns a random number from a sequence (ie it returns the current value from the sequence then increments to the next position). The sequence is initiated by srand() which sets the start point of the sequence (note adding one to the input does not move it one place down the sequence its a bit more fancy). Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
rand() returns a random number from a sequence (ie it returns the current value from the sequence then increments to the next position). The sequence is initiated by srand() which sets the start point of the sequence (note adding one to the input does not move it one place down the sequence its a bit more fancy). Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
Handling Random
rand() returns a random number from a sequence (ie it returns the current value from the sequence then increments to the next position). The sequence is initiated by srand() which sets the start point of the sequence (note adding one to the input does not move it one place down the sequence its a bit more fancy). Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
rand() returns a random number from a sequence (ie it returns the current value from the sequence then increments to the next position). The sequence is initiated by srand() which sets the start point of the sequence (note adding one to the input does not move it one place down the sequence its a bit more fancy). Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
rand() returns a random number from a sequence. The sequence is initiated by srand() which sets the start point of the sequence. Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
rand() returns a random number from a sequence (ie it returns the current value from the sequence then increments to the next position). The sequence is initiated by srand() which sets the start point of the sequence (note adding one to the input does not move it one place down the sequence its a bit more fancy). Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to cha ngechange the program from other situations (also known as tight coupling).
Also dontdon't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exlusiveexclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than seprateseparate variables. This allows you to make things more flexableflexible.
###Handling Random
rand() returns a random number from a sequence. The sequence is initiated by srand() which sets the start point of the sequence. Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to cha nge the program from other situations (also known as tight coupling).
Also dont declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exlusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than seprate variables. This allows you to make things more flexable.
Don't use global variables.
int roachesInHouseA, roachesInHouseB; //my two houses.
int temporaryHouseA, temporaryHouseB;
double totalRoachesInHouseA, totalRoachesInHouseB; //the total count of houses.
int week;
It is better to use local variables and pass them as parameters to functions. Having global variables (better know as mutable global state) makes it hard to change the program from other situations (also known as tight coupling).
Also don't declare multiple variables on a single line (don't be lazy, one variable per line).
Declare variables close to the point where you are going to use it.
Here you are declaring temporaries like a million miles from their usage point.
int temporaryHouseA = 0; // storage for arithmetic
int temporaryHouseB = 0; // storage for arithmetic
What is the difference between totalRoachesInHouseX and roachesInHouseX
int totalRoachesInHouseA = 97; // test number for A
int totalRoachesInHouseB = 79; // test number for B
This gives you a number between 10 and 110. Not quite what you want.
roachesInHouseA = rand() % 100 + 10;
roachesInHouseB = rand() % 100 + 10;
To check for things that happen every 4 weeks try:
(weeks % 4) = 0 /* Or any constant from 0 -> 3 */
I don't think the exterminator and the roach moving are exclusive. The roaches move even if the exterminator comes.
Also Its 30% of the difference (not 30% of the total).
As we have two houses exactly the same you may want to use an array rather than separate variables. This allows you to make things more flexible.
###Handling Random
rand() returns a random number from a sequence. The sequence is initiated by srand() which sets the start point of the sequence. Normally you would initiate srand() like this:
srand(time(NULL)); // Call ONLY once just after main() starts
But for testing it is nice to get the same random numbers each time you run. To do this initiate the random sequence at the same point.
srand(0); // Initiate the rand at point 0 in the sequence.