I am in need of help with this program. I am not very good.
Project 3: The Isle Royale Wolves and Moose
Please note that this project indicates precisely what your program should accomplish, without a precise indication of how the program works. Part of your assignment is designing the techniques of how the program works.
Isle Royale is a remote wilderness island, isolated by the frigid waters of Lake Superior, and home to populations of wolves and moose. As predator and prey, their lives and deaths are linked in a drama that is timeless and historic. Their lives are historic because it has been documented for more than five decades. You will continue the research project that is the longest continuous study of any predator-prey system in the world.
Each year the populations of these animals varies according to these equations:
New wolf population = (1 - d + bG)F
New moose population = (1 + r - rG/k - aF)G
The variables in these equations are:
F = last year's wolf population (try about 100)
G = last year's moose population (try about 10000)
d = death rate of wolves (try about 0.1)
b = conversion rate (try about 0.00001)
r = growth rate of moose (try about 0.4)
a = ability rate (try about 0.0005)
k = carrying capacity of island (try about 30000)
These fancy phrases probably don't mean much to you, but the equations should be enough to program the simulation. If you want to find out more about this mathematical model, see the book Population Biology by P.W. Hendrick.
This program declares a group of constants and then uses a function to compute the wolf and moose populations over a period of 100 years. The constants and prototype for the function must be exactly these. (HINT: use an unnamed namespace):
void population(int wolves[], int moose[]);
// This function uses the declared constants to compute the wolf and
// moose population for future years, putting these values in
// wolves[0]...wolves[YEARS] and moose[0]...moose[YEARS].
// THIS FUNCTION DOES NOT WRITE ANY OUTPUT.
// IT JUST PUTS THE NUMBERS IN THE ARRAY.
void computeMinimum(const int data[], int &i);
// The function examines data[0]...data[YEARS] to find the minimum entry.
// The index of this entry is placed in the parameter i.
// If there are several equally small minimum elements, then i is set
// to the index of the first such item.
// THIS FUNCTION DOES NOT WRITE ANY OUTPUT.
// IT JUST PUTS THE NUMBERS IN THE ONE REFERENCE PARAMETER.
void computeMaximum(const int data[], int &i);
// The function examines data[0]...data[YEARS] to find the maximum entry.
// The index of this entry is placed in the parameter i.
// If there are several equally large maximum elements, then i is set
// to the index of the first such item.
// THIS FUNCTION DOES NOT WRITE ANY OUTPUT.
// IT JUST PUTS THE NUMBERS IN THE ONE REFERENCE PARAMETER.
Notice that the size of the two arrays must be at least YEARS+1 since the function will compute values for wolves[0]...wolves[YEARS] and moose[0]...moose[YEARS].
For this assignment (see Springboard - no late submissions), your program must produce an output of exactly this form into a text file name report.txt:
---------- Year ---------- Wolves ---------- Moose
0 100 10000
10 215 23238
20 542 14541
30 607 8693
40 518 9005
50 502 10676
60 535 10476
70 539 9913
80 529 9975
90 527 10168
100 531 10148
The minimum population for wolves was 100 in year 0.
The maximum population for wolves was 622 in year 26.
The minimum population for moose was 8338 in year 34.
The maximum population for moose was 23404 in year 9.
Please notice that the lines of dashes in the first line of the output have exactly ten dashes each. The numbers on the subsequent lines must line up as shown in the above example. In order to align such numbers, you will need to use the setw function from #include <iomanip>. This function produces an object that is sent to the file just before printing a number. For example, to print a number x using a total of 15 spaces, you would use the statement:
file << setw(15) << x;
In addition to the items listed above, this version of the program is required to have the following items for us to test:
const int YEARS= 100; // Number of years in the simulation
const int TABLE_INCREMENT = 10; // Size of the steps in the output table
To get the initial values for the wolves and mooses, use commandline arguments to pass in these values. Be sure to validate the input and convert them to integers. (Commandline arguments will be covered in Class/Lab).
The completed program should be able to execute without printing anything to standard output. To report errors to your user use standard error! Your program should only execute if two arguments are passed into it. (myprogram.exe 100 1000)
You should write and propose other functions as needed to satisfy your sense of top-down design and the required class style guide.
This is a complex project with a lot of working parts. START EARLY!
Code:
• Use a header comment with your name and the purpose of the program.
• Your design must include breaking your code into functions
• Functions must use a separate file (.hpp)
• Functions must have header comments that include the purpose of the function and the pre-condition and post-condition documentation as well.
• Use appropriate file handling techniques and steps for ensuring file processing.
• Use appropriate techniques and steps for initializing, building and processing the arrays.
• Use appropriate code comments.
• Use appropriate variable names.
• Use good coding practices (i.e., spacing, indentation, etc.).
• Use standard error for all error message (no cout statements should be found in this program)
Submission:
On Springboard, go to the matching Dropbox for the Project #, where # is the appropriate number of the project that is assigned (eg., Project 1), and submit the program (cpp) and any other file (.hpp). Make sure it is the program only. You may use the name main.cpp, or any other suitable name of your choice.
Projects will not be graded after 11:59 p.m. on the due date.
//Supposed to produce output
//This probably won't work
using namespace std;
int main()
{
int wolves [101];
int moose [101];
const int oldwolf = 100;
const int oldmoose = 10000;
const double deathrate = 0.1;
const double conversionrate = 0.00001;
const double growthrate = 0.4;
const double wolfability = 0.0005;
const int capacity = 30000;
const int years = 100;
double newwolf = (1-deathrate + conversionrate*growthrate)*oldwolf;
double newmoose = (1 + growthrate - growthrate*oldmoose/capacity - wolfability*oldwolf)*oldmoose;
//Trying to place the initial population in their respective arrays
void population(int wolves [], int moose []);
{
wolves [0] = 100;
moose[0] = 10000;
}
//Trying to place the correct population in
//the arrays
for (int i=1; i<=years; ++i){
wolves[i]=wolves[i-1];
}
for (int i=1; i <=years; ++i){
moose[i]= newmoose*i;
}
//Trying to compute the minimum and
//maximum values for each population
void computeMinimum(const int data[], int &i);
void computeMaximum (const int data[], int &i);
//Trying to write to a text document
ofstream outFile;
outFile.open("Report.txt", fstream::in|fstream::app);
outFile<<setw (60)<<"---------- Year ---------- Wolves ---------- Moose" << endl;
outFile<< years <<;
outFile<< wolves[] <<;
outFile << moose[] <<;