Whale Simulation - Loops, Input/Output
files
Write a
C++ program to solve the following problem.
Background
Most animal species have a minimum population threshold number. What this means is that if fewer than this number
of animals exist, the population stops breeding and the species will die out,
even if there are still breeding pairs.
Sometimes
the population survival threshold is in the thousands, for example, as was the
case with the passenger pigeon. Sometimes
the threshold is low. It varies with the
species. The population survival
threshold for the Right Whale is about 165.
Currently there are about 1500 Right Whales left in the South Atlantic
(near Argentina). Their numbers continue
to decrease due to hunting pressures.
(The Right Whale is so named because it floats when killed. This makes it easier to retrieve and the
"right" whale to be killed.)
For a
current right whale update click on: http://sero.nmfs.noaa.gov/pr/mm/rightwhales/rwconservation.htm
You may
assume that
1. At
the beginning of each year, if breeding took place, the population will
increase by 5 percent due to new births.
2. No
hunting will take place at the start of the year. Therefore the entire population increase will
occur if breeding takes place.
3. About
17 percent of the population will be killed after the hunting season
starts. Include newborns in this total,
i.e. calculate after you increment the population numbers from breeding
4. As
a simplification, the gestation period can be ignored. (The gestation period is the length of
pregnancy.)
5. Breeding
stops when the population becomes less than 165.
These
assumptions are obviously not enough to accurately describe the entire
situation. What you are being asked to
do is to solve a simplified problem.
Your
task: Write a C++ program using the while loop to
calculate when the population ceases breeding and thus dies out. You do not have to input any values. Define the birth percentage, kill percentage,
and survival threshold using constant variable declarations.
Your
output (to a file) should be similar to this.
|
YEAR |
ALIVE AT START |
NEW
BIRTHS |
KILLED |
ALIVE
AT END |
|
1 |
1500 |
75 |
267 |
1308 |
|
2 |
1308 |
65 |
233 |
1140 |
|
3 |
1140 |
57 |
203 |
994 |
|
. |
. |
. |
. |
. |
|
. |
. |
. |
. |
. |
This
program written by Insert your name here.
In your
calculations, do not count fractional births or deaths. For example, 6.3 should be considered to be 6
and 45.8 should be considered to be 45.