Question

HAND IN LABORATORY TASK: #17( if you get an A grade your earn 20pts for AVG) 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 Island as the years go by with the following conditions. BE SURE TO DOA FLOW CHART FIRST AND HAND IN WITH THE PROGRAM 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 its 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 its 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?

Using C++ program please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q1: Code for problem 1

#include <iostream>

using namespace std;
int main()
{
int foxes=20;
int rabbits=13000;
int year=1;
int good=0;
int bad=0;
int die;
cout<<"Year\t"<<"Foxes\t"<<"Rabbits"<<endl;
while(year<=30)
{
cout<<year<<"\t"<<foxes<<"\t"<<rabbits<<endl;
if(rabbits>foxes*208 && foxes!=0)
{
rabbits-=foxes*208;
foxes=foxes*1.15;
rabbits*=1.5;
good++;
}
else if(rabbits<foxes*208 && foxes!=0)
{
rabbits-=foxes*52;
foxes=foxes*1.03;
rabbits*=1.5;
bad++;
}
if(rabbits<0)
{
foxes=0;
rabbits=0;
die=year;
break;
}
year++;
}
cout<<"Good years="<<good<<"\t"<<"Bad years="<<bad<<"\t"<<"Dies in the year="<<die<<endl;
}

There can be two interpretations of year in which they die as in the year in which there is not sufficient rabbits to feed the foxes(I have written code according to this.) or the next year of this because the foxes would have vanished in that year

Q2: Code Including the change(if we assume that foxes are killed before they have reproduced)

#include <iostream>

using namespace std;
int main()
{
int foxes=20;
int rabbits=13000;
int year=1;
int good=0;
int bad=0;
int die=0;

cout<<"Year\t"<<"Foxes\t"<<"Rabbits"<<endl;
while(year<=30)
{
int killed=0;
cout<<year<<"\t"<<foxes<<"\t"<<rabbits<<endl;
if(rabbits>foxes*208 && foxes>0)
{
rabbits-=foxes*208;
killed=foxes*0.05;
foxes=foxes-killed;
foxes=foxes*1.15;
rabbits*=1.5;
//the code should work according to me.
good++;

}
else if(rabbits<foxes*208 && foxes>0)
{
rabbits-=foxes*52;
foxes=foxes*1.03;
rabbits*=1.5;
bad++;
}
if(rabbits<0)
{
foxes=0;
rabbits=0;
die=year;
break;
}
year++;
}
cout<<"Good years="<<good<<"\t"<<"Bad years="<<bad<<"\t"<<"Dies in the year="<<die<<endl;
}

If you want that foxes are killed after they have reproduced then you just have to change the order of statements in for if statement.

The killers actually made the good years increased in numbers as the foxes had 5 good years and 3 bad years earlier but now they had 7 good years and 1 bad year before they don't have enough rabbits to survive.

Q3

If 10% of foxes are killed every good year then foxes will survive with 30 good years

It is assumed that if foxes=21.245(say) then we have only 21 foxes.I hope that you understand that I have taken integer lower than the foxes value.

So the output in the case where 10% foxes are killed the foxes remain 20 because of this truncation.

Please do upvote my answer by giving it a thumbs up.

Thank You.

Add a comment
Know the answer?
Add Answer to:
Using C++ program please HAND IN LABORATORY TASK: #17( if you get an A grade your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Evaluate the arical writ the response in which you state your agreement or disagreement with writer...

    Evaluate the arical writ the response in which you state your agreement or disagreement with writer up un these questions guidelines 1) can empathy lead us astrary? how 2) our heart will always go out to the baby in the well, its a measure of our humanity. but empathy will have to yield to reason if humanity is to have a future can empathy yield to reason? how? thank you The Baby in the Well: The Case against Empathy* -Paul...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Read about Cokes strategy in Africa in the article below and discuss the ethics of selling...

    Read about Cokes strategy in Africa in the article below and discuss the ethics of selling soft drinks to very poor people. Is this an issue that a company like Coke should consider? Africa: Coke's Last Frontier Sales are flat in developed countries. For Coke to keep growing, Africa is it By Duane Stanford Piles of trash are burning outside the Mamakamau Shop in Uthiru, a suburb of Nairobi, Kenya. Sewage trickles by in an open trench. Across the street,...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT