Results 1 to 3 of 3
  1. #1
    westerbamos is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default 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);
    }

    }
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help writing a program to study population growth

    What sort of 'wrongness' did you experience?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    westerbamos is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default 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.

Similar Threads

  1. Help with writing my own program
    By DMarsh12 in forum New To Java
    Replies: 4
    Last Post: 12-30-2011, 03:34 AM
  2. Replies: 0
    Last Post: 11-15-2010, 11:37 AM
  3. Combo Box Population
    By barusk in forum Java Applets
    Replies: 1
    Last Post: 03-20-2009, 01:48 PM
  4. Due Tommorow Writing a Program Please Help
    By gallimaufry in forum New To Java
    Replies: 4
    Last Post: 10-23-2008, 03:15 AM
  5. Replies: 1
    Last Post: 08-09-2008, 11:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •