Trouble with my counter increments

I'm trying to create a counter that increases in increments of two in the first column and then also increases in the second column with the numbers in the first column. The user is supposed to enter the rate at which their hose can put 2 inches of water in a pool (in inches/hour). We are supposed to determine the time (in hours) the user's hose can fill the pool (66 inches total), outputting time in increments of 2 inches until to pool reaches 66" of water. The calculation for time is (inches / fill_rate). I got the left column to increase in increments of 2 all the way up to 66 but the right column is only displaying what the time would be for the first two inches.

For example, if the user-entered fill rate is 2 then it would take one hour to fill 2 inches in the pool. The left column displays 2-66 in increments of two but the right column is just outputting "1" from 2-66. I need the right column to increase with the numbers on the left. So if the number in the left column is 2 then the associated right column number would be 1. If the left column number is 4 then the associated right column number would need to be 2. . . and so on until 66 is reached.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// The counter.
	const int min_number = 2;
	const int max_number = 66;
	int num = min_number;	// Counter
	double timeCalc = (num / fill_rate);
	cout << "Your fill rate is 2 inches every " << timeCalc << " hours." << endl;


		cout << "Time Intervals Per 2 Inches Gained" << endl;
		cout << "----------------------------------" << endl;
		while (num <= max_number)
		{
		cout << num << "\t\t" << timeCalc << endl;
		num = num + 2;
		}
Last edited on
You need to recalculate timeCalc every iteration in your while loop.
You're only doing it once when num = 2.
I've been trying to figure out how to do that. Would I do the same thing to timeCalc that I did for num?
I forgot I posted a response here. Sorry.
Right above your cout in your while loop put timeCalc = (num / fill_rate);
It should work if I understand what you were going for.
Topic archived. No new replies allowed.