Java Project: Population Growth


The United Nations (UN) has set forth 17 goals for sustainable development. Goal 3 is designed to “Ensure healthy lives and promote well-being for all at all ages.” Well-being has many different facets – physiological, psychological, and others – but all require access to resources, including medicine, education, clean water, healthy food, and education. Many parts of the world still suffer from an abundance of treatable diseases and premature mortality.

In this project, we will consider population growth and decline. Changes in population levels can occur due to a variety of issues, including but not limited to climate-influenced fertility issues, access to sufficient resources, and the spread of communicable diseases.

The Growth and Decline of a Population

The rate of population growth (or decline) has a direct impact on the utilization of society’s resources – fuel, food, etc. – and can impact the health and sustainability of the surrounding environment. Just as populations of some animals are carefully managed (e.g. deer) to promote the overall health of the species, the human population has been undertaking a number of behavior modifications (e.g. recycling, use of of new power sources) designed to promote a more sustainable planet and, ultimately, the continuance of life. However, the world’s population continues to grow at a steady rate. For example, the population of the U.S. is expected to reach 400 million people by 2055.

Check out the following brief video for a summary of these concepts:

Where Can I Learn More?

Here are some links to additional information on this topic:

In this program we will use a simple mathematical model to compute the growth or decline of a population over time.


Java Program: Population Growth

In this project will provide you with an introduction to the fundamentals of conditional repetition in Java. The focus of this project is on how to solve a simple problems using Java primitive data types, variables, if statements, loops, and arithmetic operations. In this project, you will…

  • Develop code to read data from the standard input and produce data to the standard output.
  • Translate a given mathematical expression into equivalent syntactically correct programming statements.
  • Write code that conforms to a programming style specified by the instructor.
  • Select and implement the appropriate control structure(s) for this problem.

As you write your code, be sure to properly document your code. Consult the Java Coding Guidelines document (provided by the instructor) for style expectations. Well-written code is easier to debug, easier to maintain over time, and easier to extend as new requirements arise.

The Mathematics of Population Growth

A number of mathematical models exist to determine population growth over time; in this lab, we will consider a simple model which assumes a static growth rate. There are many factors that can affect the growth or decline of a population, but two of the more basic factors are birth rates and death rates. These rates can be measured and can be used to predict how the population’s size will change over time. To find a change in population size N over a fixed time interval (ΔN), we begin with this equation:

$$r = b\; -\; d$$

This equation represents the difference between the average number of births and deaths per individual during the fixed time interval. The variable b represents the per capita birth rate (the number of offspring per unit of time for an average individual), where similarly, d is the per capita death rate. When r = 0, the birth rates and death rates are equal, and this is defined as Zero Population growth (ZPG).

We can use this to determine the population (N) at the end of the current year (year i), by adding this new value to the population from the prior year (year i-1):

$$N_{i}\; = \; N_{i-1} \; + \; rN_{i-1}$$

If population growth is experienced under ideal conditions, the growth is referred to as exponential population growth because the curve of population size vs. time is a j-shaped curve that corresponds to the graph of an exponential function. Exponential growth appears in populations that have been drastically reduced and are now rebuilding their population.

Exercise

Create a Java class (program) called PopulationGrowth.java. This program will compute the growth rates of a population over time. The program should take the following inputs from the user:

  • p, the initial population size in the range [1…1000]
  • b, the per capita birth rate in the range [0.0…1.0)
  • d, the per capita death rate in the range [0.0…1.0)
  • time_span, the number of years for which to compute population totals

Once the input is finished, the program must compute the population for the next time_span years and display each year’s total to the screen. Use the formulas provided in the previous section to perform the necessary computations.

The output report should have two columns of information: Year and Population Size. Remember that the first year is considered Year 0, not Year 1. You must use a while loop for your calculations! Be aware that it is possible for the population to go extinct (i.e. have a population ≤ 1.0); at that point you must stop processing, close the report, and inform the user.

Two test cases are provided below:

Test Case #1 (Growth – Increased Fertility)

Enter the initial population size [1-1000]: 100
Enter the birth rate [0.0...1.0): 0.5
Enter the death rate [0.0...1.0): 0.4
Enter the number of years [1...100): 10

      YEAR     POPULATION

         0            100
         1            110
         2            121
         3            133
         4            146
         5            160
         6            176
         7            193
         8            212
         9            233

Test Case #2 (Extinction – Disease Epidemic)

Enter the initial population size [1-1000]: 100
Enter the birth rate [0.0...1.0): 0.4
Enter the death rate [0.0...1.0): 0.7
Enter the number of years [1...100): 15

      YEAR     POPULATION

         0            100
         1             70
         2             49
         3             34
         4             23
         5             16
         6             11
         7              7
         8              4
         9              2
        10              1
        11              0

The population has gone extinct.

Deliverables

See the instructor for submission instructions and due date(s).

Powered by WordPress. Designed by WooThemes

Skip to toolbar