[y] # of rabbits in year y f[y] # of foxes in year y α or alpha - birth rate of rabbits β or beta - death rate of rabbits, dependent on # of foxes

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 2PP: (Mechanics) The deflection at any point along the centerline of a cantilevered beam, such as the one...
icon
Related questions
Question

PYTHON  (Uee While Loop) only

Write a python program that calculates the populations of foxes and rabbits who live within a certain area of land, as that number changes from year to year. It will take the initial populations as inputs, and then proceed to calculate the year-by-year changes.

The following is derived from the “Lotka-Volterra equations”, which you may look up if you desire. Essentially, we will model the foxes and rabbits with 4 constants, and 2 data structures of year-by-year values. They are defined as follows:

  • r[y] # of rabbits in year y
  • f[y] # of foxes in year y
  • α or alpha - birth rate of rabbits
  • β or beta - death rate of rabbits, dependent on # of foxes
  • γ or gamma - birth rate of foxes, dependent on # of rabbits
  • δ or delta - death rate of foxes, caused naturally

The formulas we will use are:

r[y]=r[y−1]+(r[y−1]×α)−(r[y−1]×f[y−1]×β)r[y]=r[y−1]+(r[y−1]×α)−(r[y−1]×f[y−1]×β)

f[y]=f[y−1]+(f[y−1]×r[y−1]×γ)−(f[y−1]×δ)f[y]=f[y−1]+(f[y−1]×r[y−1]×γ)−(f[y−1]×δ)

However, negative values are not allowed! If either formula results in a negative value, you should use 0 instead.

You will start out by asking the user how many years of simulation he or she wants, and what the initial numbers of rabbits and foxes are. Each of these populations of animals needs to be held in its own data structure. The first elements of each data structure holds the initial populations, and subsequent elements are calculated using the above formulas. (Remember that single-letter names are
usually horrible. Don’t call your rabbit and fox data structures r and f–those names are just for the
equations above.)

We will use the values of α = 0.2, β = 0.005, γ = 0.001, and δ = 0.2. You should print out each year’s populations as you calculate them, and then give a final report at the end with all of the calculations. Here is how your program should appear. Note these values are not accurate:

Year 0: 50 rabbits, 10 foxes
Year 1: 200 rabbits, 4 foxes
Year 2: 133 rabbits, 6 foxes

Rabbit populations: [50, 200, 133]
Fox populations: [10, 4, 6]

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning