Question
Can you check this code and if it has any mistake please fix it #include #include using namespace std; int main() { //---------------------------------------------------------------------------------------------------------------------(DATA) int noOfFoxes
Can you check this code and if it has any mistake please fix it
#include
int main() { //---------------------------------------------------------------------------------------------------------------------(DATA)
int noOfFoxes = 20; //initial number of Foxes int rabbits = 13000; //intial number of rabbits int year = 1;
float huntedFoxesPercentage = 0.05;
//------------------------------------------------------------------------------------------------------------------------(WORKING)
for (int count = 0; count
for (; rabbits > 0;) {
if (rabbits >= noOfFoxes * 208) {
rabbits = rabbits - (noOfFoxes * 208); //yearly deaths at the hands of Foxes rabbits = rabbits + (rabbits / 2); //after reproduction
noOfFoxes = noOfFoxes + (0.15 * noOfFoxes); //foxes reproduced in a good year noOfFoxes = noOfFoxes - (huntedFoxesPercentage*noOfFoxes); //foxes killed by hunters in a good year
}
else if (rabbits
rabbits = rabbits - (noOfFoxes * 52); //yearly deaths at the hands of the Foxes in a bad year rabbits = rabbits + (rabbits / 2); //after reproduction
noOfFoxes = noOfFoxes + (0.03 * noOfFoxes); /oOfFoxes after reproduction in a bad year
}
if (rabbits
cout
if (rabbits == 0) { cout = noOfFoxes * 208) {
cout
cout
cout
cout
year++; }
cout
int noOfFoxes = 20; int rabbits = 13000; int year = 1;
float huntedFoxesPercentage = 0.15;
}
cout
//--------------------------------------------------------------------------------------------------------------------------(END) system("PAUSE");
return 0; }
HAND IN LABORATORY TASK: LAB #18 (DOUBLE VALUE) FOX HEAVEN an island off the coast of Costa Rica near Isla Sorna REPORTS OF STRANGE CREATURES ON THIS ISLAND Write a program to study the population of foxes ON Fox Heaven lsland as the years go by with the following conditions You study the island and count the foxes at 20 with a lot of rabbits, namely 13,000 rabbits Looks like plenty of rabbits to keep this island going for a long time. So in your study you find information About the fox and rabbit reproduction and build this program to predict the future for the island As follows: If every thing is ok, ie a GOOD YEAR foxes can survive by eating 208 rabbits for the year That means that a good year is if the total number of rabbits is greater than the number of present foxes times the 208 rabbits, if the present number of rabbits falls below the good year then it's a BAD YEAR AND AND FOXES WOULD NEED TO EAT ONLY 52 RABBITS TO JUST SURVIVE very skinny. In a good year the rabbit population goes down by number eaten foxes 208 and the remaining rabbits goes up by 50% And the foxes population increases 15% of the previous years value but if year is bad (#of rabbits foxes *208) ie not enough rabbits to fully satisfy the foxes and keep them healthy so they go on a lean diet of only eating 52 rabbits a year as noted above. So rabbits population goes Down by #foxes x 52 and the remaining rabbits increase by 50% (they are still healthy) The fox population grow now at only 3% (the fox population is stressed and the rabbits remaining increase by 50% (they are still healthy) These rates of 50%, 15% and 3% includes a combination of births and deaths from various other courses 1. Write a program with year 1 starting numbers of foxes and rabbits as above. Have it calculate the first good year And see how many rabbits and foxes there are then check to see if it's a good or bad year and use the rates above Output the year, the fox population, rabbit population in nice labeled table. Run for 30 years. Can FOX HEAVEN sustain itself, if the rabbit population drops below zero then the foxes all die Set fox number to zero for negative rabbits thus all on the island die. USE WHILE FOR YEARS AND IF-ELSE FOR DECISIONS Note on your hand in. How many good years, What year(s) did the island turn bad? What year does it die? 2. Take into account that the island has been discovered by "Brits" who hunt foxes in a good year only for good pelts The hunters kill 5% of the foxes during the good year. Rerun the program for as many years you need to see if the island Survives, flourishes or dies. If it goes bad what year(s)? And what year does it die if it does? Look at the behavior carefully, anything Interesting? Did the hunters make the situation on the island worse or better or the same in this case? Explain?? 3. Rerun and change kill of the hunters and figure out how high must it be to keep the island going for 30 year
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started