Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+2 votes

Within the for loop, I was able to to get max/min with for loop. The program prints out the time t = in columns with the respective data for foxes and rabbits. How do I join this time with the max/min?

asked in CSC201 by (8 points)

Ah, I got it

1 Answer

+1 vote

So it's not a matter of just printing them, you are going to have to have a variable that stores the value that you want to print.

What's the strategy for finding the time to go along with the max/min?

The basic idea is that every time you update the maximum accumulator in the loop, you would also need to save the year that you are processing. That year is likely the loop control variable. If you are going to update within the loop, then initialize before the loop.

1) initialize a variable like maxFoxYear to the initial year (0) before the loop
2) In the loop, update maxFoxYear if you update the maximum population

Same idea for the min.

answered by (8 points)