# Help writing a program to study population growth

• 02-12-2012, 10:58 PM
westerbamos
Help writing a program to study population growth
I am currently working on a program for class:

"Write a program to study the following simple model for population growth, which might be applied to study fish in a pond, bacteria in a test tube, or any of a host of similar situations. We suppose that the population ranges from 0 (extinct) to 1 (maximum population that can be sustained). If the population at time t is x, then we suppose the population at time t + 1 to be r*x*(1 - x), where the argument r, known as the fecundity parameter, controls the rate of growth. Start with a small population-- say, x = 0.01-- and study the result of iterating the model, for various values of r. For which values of r does the population stabilize at x = 1 - 1/r? Can you say anything about the population when r is 3.5? 3.8? 5?"

Here is what I have so far, can someone please help me figure out what I am doing wrong?

public class Chaos
{
public static void main(String[] args)
{
double t = Double.parseDouble(args[0]);
double x = Double.parseDouble(args[1]);
double r = Double.parseDouble(args[2]);
for(x = 0.01; x >= 0 && x <= 1; t++) {
x = (r*x*(1 - x));
System.out.println(1 - 1/r);
}

}
}
• 02-12-2012, 11:18 PM
JosAH
Re: Help writing a program to study population growth
What sort of 'wrongness' did you experience?

kind regards,

Jos
• 02-12-2012, 11:26 PM
westerbamos
Re: Help writing a program to study population growth
When i use the command line arguments 0 0.1 1 the program prints out 0.0 over and over again and does not stop. I'm not sure if my for loop is set up right, I was having trouble deciding whether to use x or t or r in the for loop.