Question

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 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;
}
if(rabbits<0)
{
foxes=0;
rabbits=0;
die=year;
break;
}
year++;
}
}

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 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;
}
if(rabbits<0)
{
foxes=0;
rabbits=0;
die=year;
break;
}
year++;
}
}

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.

Thank You.

#### Earn Coins

Coins can be redeemed for fabulous gifts.

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 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...