Stuck again. Determines the size of the green crud population on any given day.
// Assumes that green crud reproduces every 5 days starting when
// it is 10 days old,giving a growth rate following the Fibonacci sequence.
// So if there is a new crud population of 10 pounds on day 0, the
// crud population at increments of 5 days beginning with day 0 are as follows:
// 10, 10, 20, 30, 50, 80, 130, ...
// That is, on day 0 there are 10 pounds; on day 5 there are still 10 pounds;
// on day 10 there are 20 pounds; on day 15 there are 30 pounds; and so on.
// **************************************************************************

There are two basic loop tasks:(1) update the day, and (2) if it's a fifth day, update the amounts of crud. On the fifth day the old crud produces baby crud (you'll need a variable to store this); both the old crud and the new crud are now old crud; and the baby crud is new crud.

Even with all of these hints, I'm at a loss as to how to proceed. I am not sure to use a while or a for or a combo or what??
Thanks
RG

I think I understand the old and new variable, but I don't see how to loop through the user's input and store values......

If I'm reading this correctly, you don't need user's input. [edit maybe you do]

Have you drawn a flow chart.

....have you drawn a flow chart.....

Not yet...I wrote out a few expressions, then I keep getting frustrated

Upload a picture of your flow chart if possible.

If you are using word you can draw the flow chart symbols easily.

Flow charting was not taught to me in my C++ class - and it was discouraged. I had some in 1989 for a Basic programming class, but that was then........

So what's the difference between these two?

for ( day = 0 ; day < 100 ; day++ ) {
  if ( day % 5 == 0 ) {
    theNextGeneration();
  }
}
for ( day = 0 ; day < 100 ; day += 5 ) {
    theNextGeneration();
}

The rest is nothing more than a Fibonacci series.

This article has been dead for over six months. Start a new discussion instead.