273-422X/Y-61 OBJECT ORIENTED DESIGN Assignment # 1
-----------------------------------------------------
Write a C++ program that simulates the population of hares and lynxes
in an ecosystem.
Assume that the populations are governed by the following equations:
H = H0 + a*H0 - b*H0*L0
L = L0 + c*L0*H0 - d*L0
where H0 is the number of hares in the current year,
L0 is the number of lynxes in the current year,
H is the number of hares in the coming year,
L is the number of lynxes in the coming year,
and a, b, c, d are constants that determine the relative effect
of the lynx and hare populations on each other.
(a is the birth rate for hares, b is the rate (per lynx) at which hares
get eaten, c is the birth rate (per hare) for lynxes, d is the death rate
for lynxes. Note that these constants must all be non-negative and
the constant d cannot exceed 1.0 )
The number of hares or lynxes cannot be negative, so the above equations
should be understood as giving zero if the right hand side is negative.
Your program should prompt the user to enter the following values
at the keyboard: (The input values shoule be checked for validity but it is
not necessary to be user-friendly - the program can just exit on bad input.)
- the value of a, b, c, d (non-negative floating point values)
- the initial number of lynxes
- the initial number of hares
- the duration of the simulation in years
It should then use the above equations to calculate the changes in the
lynx and hare population from year to year, iterating for the number of years
specified. For each year in the iteration, the lynx and hare populations
should be output to the screen.
Use functions to do the calculation of the number of hares and lynxes
in the coming year.
Eg. int lynx_population( int num_lynx, int num_hare,
float lynx_birth_rate, float lynx_death_rate )
returns the number of lynxes for the coming year given the current number
of lynxes and hares and the lynx birth and death rates.
Respect the style guidelines - especially with regard to documentation
and meaningful variable names. Each part of your program should be
understandable on its own since the variable names shoule be more meaningful
than those used above and the documentation for each function should enable
the purpose of the function to be understood without reference to its
implementation.
Try your program out with a number of different combinations of initial
numbers of hares and lynxes and birth and death rates.
Eg. 2000 hares, 100 lynxes, a=0.2, b=0.001, c=0.0003, d=0.4
is interesting.