Project: Population Growth

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 has been growing at a steady rate, as shown below:

worldpop

You may be surprised to learn that many advancements in science, medicine, and technology, are fueling the steady growth and population. Before proceeding, check out this short NPR video about how and why the population has grown over time:

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 over a fixed time interval, use the formula:

popgrowth1

Where:

  • ΔN is the change (Δ) in population size;
  • Δt is the change in time, a fixed interval;
  • B is the number of births; and
  • D is the number of deaths.

This equation can be modified to represent the average number of births and deaths per individual during the 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. Using N to represent population size, the equation becomes:

popgrowth2To identify the difference in per capita birth and death rates this equation becomes:

popgrowth3

When r = 0, the birth rates and death rates are equal, and this is defined as Zero Population growth (ZPG). Combining the previous two equations gives the overall equation:

popgrowth4

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.

Click on the following image to see a brief YouTube video (http://youtu.be/sgI-KrbPYRU) which demonstrates the growth of a population over time, where (b-d) = 1.5:

In this project, we will use a modified form of this logic to simulate population growth.

C++ Project: Population Growth

This project will provide you with an introduction to the fundamentals of conditional repetition in C++. In this project, you will…

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

As always, be sure to properly document your code. Consult the C++ Coding Guidelines for proper coding standards. Use good design principles and design the solution before attempting to write code.

Exercise #1: Create a new file called PopulationGrowth.cpp. In this exercise you will write a program to compute the growth rates of a population of Pixies over time. Your program should take the following inputs from the user:

  • p, the initial population size in the range [1…1000] (a double);
  • b, the per capita birth rate in the range [0.0…1.0) (a double);
  • d, the per capita death rate in the range [0.0…1.0) (a double).

All input values should be validated according to the rules above. Once the input is finished, perform your calculations for the next 50 years and display them to the screen. Your 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 ≤ 0.005); at that point you must stop processing, close the report, and inform the user. The population in any year is a function of two things: the current population (i.e. last year’s population) and the difference in per capita birth and death rates (r). The following equations may be handy:

popgrowth5

Remember that the population at year 0 is the initial population. Your numerical output should be precise to two decimal places on the right of the decimal for all real-number data.

Compile and Build your program to verify it works as expected. Two sample output dialogs are provided below. Don’t forget to test the input validation!

Test Case #1 (Growth)

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

                YEAR                    POPULATION

                   0                        100.00
                   1                        110.00
                   2                        121.00
                   3                        133.10
                   4                        146.41
                   5                        161.05
                   6                        177.16
                   7                        194.87
                   8                        214.36
                   9                        235.79
                  10                        259.37
                  11                        285.31
                  12                        313.84
                  13                        345.23
                  14                        379.75
                  15                        417.72
                  16                        459.50
                  17                        505.45
                  18                        555.99
                  19                        611.59
                  20                        672.75
                  21                        740.02
                  22                        814.03
                  23                        895.43
                  24                        984.97
                  25                       1083.47
                  26                       1191.82
                  27                       1311.00
                  28                       1442.10
                  29                       1586.31
                  30                       1744.94
                  31                       1919.43
                  32                       2111.38
                  33                       2322.52
                  34                       2554.77
                  35                       2810.24
                  36                       3091.27
                  37                       3400.39
                  38                       3740.43
                  39                       4114.48
                  40                       4525.93
                  41                       4978.52
                  42                       5476.37
                  43                       6024.01
                  44                       6626.41
                  45                       7289.05
                  46                       8017.95
                  47                       8819.75
                  48                       9701.72
                  49                      10671.90

Test Case #2 (Extinction)

Enter the initial population size (1-1000): 10
Enter the Birth Rate [0.0...1.0): 0.4
Enter the Death Rate [0.0...1.0): 0.6

                YEAR                    POPULATION

                   0                         10.00
                   1                          8.00
                   2                          6.40
                   3                          5.12
                   4                          4.10
                   5                          3.28
                   6                          2.62
                   7                          2.10
                   8                          1.68
                   9                          1.34
                  10                          1.07
                  11                          0.86
                  12                          0.69
                  13                          0.55
                  14                          0.44
                  15                          0.35
                  16                          0.28
                  17                          0.23
                  18                          0.18
                  19                          0.14
                  20                          0.12
                  21                          0.09
                  22                          0.07
                  23                          0.06
                  24                          0.05
                  25                          0.04
                  26                          0.03
                  27                          0.02
                  28                          0.02
                  29                          0.02
                  30                          0.01
                  31                          0.01
                  32                          0.01
                  33                          0.01
                  34                          0.01
                  35                          0.00
                 
The population has gone extinct.

Exercise #2: Copy PopulationGrowth.cpp as PopulationGrowth2.cpp. Modify your code to use a for loop instead of a while loop. Re-run your program with the test data to make sure it still provides the correct results.

Deliverables

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

Powered by WordPress. Designed by WooThemes

Skip to toolbar