Question

We have to write some code to simulate rabbits population growth in Australia. We have determined...

We have to write some code to simulate rabbits population growth in Australia. We have determined that the rabbit population doubles every month. For example month 1- 2 rabbits, month 2 –4 rabbits, month 3 – 8 rabbits … We also have some dingo dogs who eat rabbits and who also increases in population. Each dingo dog eats 4 rabbits each month. The dingo population doubles every 6 months. (assume no deaths in dingoes, no one eats a dingo dog) I want to know how many rabbits and how many dingo dogs exist after 4 years.   Our initial population of rabbits is 14 and our initial population of dingo dogs is 2. Write the code to compute these population values after 4 years.

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

Code

#include<iostream>

using namespace std;

int main()
{
   int rabbits = 14, dogs = 2;
   for (int i = 1; i <= 12*4; i++)
   {
       if (i % 6 == 0)
           dogs = dogs* 2;
          
       rabbits = rabbits * 2;
       rabbits = rabbits - (4 * dogs);
   }
   cout << "After 4 years population of rabbits are: " << rabbits << endl;
   cout << "After 4 years population of dogs are: " << dogs << endl;
   system("pause");
   return 1;
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
We have to write some code to simulate rabbits population growth in Australia. We have determined...
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
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