I recently got a question by my tutor to wite a program in C++ and the question is as follows so can someone else try out with it by writing another program in C++ since i have already written it in 2 ways and would like someone else to try it and let me know if it works please

  • The question is

"Population Model
Suppose that in a given month the number of Kernighan in sector i is pop_k[i], and the population of Ritchies is
pop_r[i]. The number of Kernighans in sector i changes as follows:
• The population pop_k[i] decreases by alpha_k · pop_k[i]. This is the number of Kernighans that
would starve if there were no Ritchies to eat.
• The population pop_k[i] increases by beta_k · pop_k[i] · pop_r[i]. This is the number of new
Kernighans because they can feed on Ritchies.
• The population pop_k[i] decreases by gamma_k · pop_k[i]2. This decrease in the number of
Kernighans is due to competition between Kernighans.
• The population pop_k[i] increases by omega_k · pop_k[left(i)]. This is the number of Kernighans that
migrated from the sector to the left of sector i.
• The population pop_k[i] increases by omega_k · pop_k[right(i)]. This is the number of Kernighans that
migrated from the sector to the right of sector i.
• The population pop_k[i] decreases by 2 omega_k · pop_k[i]. This is the number of Kernighans that
migrated from the sector i to one of the two neighbouring sectors.
• If the result of this computation is smaller than 0.001, then there are no Kernighan fish left.
The number of Ritchies in sector i changes as follows:
CS111 – Assignment 1 – 2013 – Page 4 of 10
• The population pop_r[i] increases by alpha_r · pop_r[i]. This is the number of new Ritchies, if there
were no Kernighan to eat them..
• The population pop_r[i] decreases by beta_r · pop_k[i] · pop_r[i]. This is the number of Ritcchies
eaten by Kernighans.
• The population pop_r[i] decreases by gamma_r · pop_r[i]2. This decrease in the number of Ritcchies
tis due to competition between Ritchies.
• The population pop_r[i] increases by omega_r · pop_r[left(i)]. This is the number of Ritcchies that
migrated from the sector to the left of sector i.
• The population pop_r[i] increases by omega_r · pop_r[right(i)]. This is the number of Ritcchies that
migrated from the sector to the right of sector i.
• The population pop_r[i] decreases by 2 omega_r · pop_r[i]. This is the number of Ritcchies that
migrated from the sector i to one of the two neighbouring sectors.
Measurements have shown that the constants have the following values:
• alpha_k = 0.4;
• beta_k = 0.4
• gamma_k=0.036
• omega_k=0.1
• alpha_r = 0.2;
• beta_r = 0.2
• gamma_r=0.036
• omega_r=0.1
Instructions
You are asked to implement a simulator that computes the populations for a given number of months for all
sectors. This simulator has to take into account the predator-prey model and the influence of migration. It
should give the user an option to set the population of Ritchies in a randomly selected sector to 0."

  • This is what is required

**"Please implement the main function, i.e give the code for the simulator, following the structure given by the
following pseudo code.
//Print welcome message
//Ask how many months to simulate
//Initialise populations in all sectors to 1
//Set the populations of Ritchies in a random sector to 0, if user want to.
//Print header of the table
//Print the population for months 0
//For each month
//For each sector
//Compute new populations
//Copy new populations to populations
//Display populations
//Return

Important: In all your program constructs you must write comments where necessary. Do not write comments
for obvious code, but for segments which seem complex.**

Show us the code you've got and outline where the problems are and we'll help you fix it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.