Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HAND IN LABORATORY TASK: #17( if you get an A grade your earn 20pts for AVG) FOX

ID: 3704504 • Letter: H

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 th following conditions. BE SURE TO DO A 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 when the total number of rabbits is greater than the present number of foxes times the 208 rabbits(so plenty to eat), if the present number of rabbits falls below the good year then it's a BAD YEAR A AND FOXES WOULD NEED TO EAT ONLY 52 RABBITS TO JUST SURVIVE becoming very skinny So In a good year the rabbit population goes down by number eaten or # 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

Explanation / Answer

Code for 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 "<<"Foxes "<<"Rabbits"<<endl;

while(year<=30)

{

cout<<year<<" |<<foxes<<" "<<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<<" "<<"Bad years="<<bad<<" "<<"Dies in the year="<<die<<endl;

}

There can be two interpretations is not sufficient rabbits to fee the foxes would have vanished in that year

2.

#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 "<<"Foxes "<<"Rabbits"<<endl;

while(year<=30)

{

int killed=0;

cout<<year<<" "<<foxes<<" "<<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<<" "<<Bad years="<<bad<<" "<<Dies in the year="<<die<<endl;

}

If you want that foxes are killed reproduced then you just have to change the order of statement.

The killers actually made the good years 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 enough rabbits to survive.

3.

If 10% then foxes will survive with 30 good years

It is assumed that if foxes=21.245 then we have only 21 foxes.

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