A farmer has a bunny farm. He has cage capacity for a limited number of bunnies. A pair of adult bunnies will give birth to 2 bunnies (1 male and 1 female) at the end of every three months. A bunny is an adult when he or she reaches the age of 4 months. (i.e. 1st pair at age 3 months give birth to1 male and 1 female at the end of the 4th month). For example:
Number of months Number of bunnies
0 2
3 4
6 8
9 16
12 32
and so on……….
Write a complete C++ program to do the following:
1. Prompt the user to enter the total capacity of the cage.
2. Determine when the farmer will have to separate the bunnies in order to prevent the birth of any more.
3. Convert the above time in months to years and months.
4. Determine the number of bunnies that could still be accommodated in the cage when the bunnies were separated.
5. Prompt the user to input a time (in months) to check how many bunnies are present at a given time.
6. Print your results as indicated on the next page.
HelmsK85
0
Newbie Poster
Recommended Answers
Jump to PostYou will probably get NO useful responses by spamming this board with your homework assignments. Since you did not as a question I suppose you expect somebody to do the work for you.
Jump to PostThen why did you start a new thread?
start here.
#include <stdio.h> int main() { // put your code here return 0; }
You may want to work through the program math on paper before starting to code so that you understand the math part.
Jump to Post>> Do I need to put a table or can I get the results I want without one?
Don't know -- since the problem doesn't say one way or the other I suppose you can do it however you want.
All 13 Replies
Salem
5,138
Posting Sage
HelmsK85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
HelmsK85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
HelmsK85
0
Newbie Poster
HelmsK85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
HelmsK85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
HelmsK85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Dave Sinkula
2,398
long time no c
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.