C++ beginner birth rate program

Hey guys, I am very new to c++ and I need to write a program that asks the user "How many sheeps do you have?" and "How many generations do you want to wait?". Each generation the sheeps get a 3% increase and a 1% decrease.

(If you were to start with 132 jackalopes, then 3 would be born (132 * 0.03 = 3.96, rounded down to 3) and of the 135, 1 would die, leaving us with 134 jackalopes. The following generation, 3% of the 134 would produce 4 births, and 1% of 138 would produce 1 death, leaving us with 137.)

I know how to do the part where it asks the user for the sheeps and generations, but i dont know how to do the rest. Can someone please help me?
show your code,i can help you to see where your error is and make corrections,but i won't make your code!,..peace!
the thing is i dont know where to start...because im taking an online class and the book does not really give too much understanding
Well, what do you about C++ to make such a thing and what don't you know?

It'll be the best if we would send you in a direction. If we would make your code you won't learn as much.
Last edited on
#include <iostream>
using namespace std;

int main()
{

int origpop, gen, newpop;
const int birth = origpop + .03
cout << "How many jackalopes do you have?";
cin >> origpop;
cout << "How many generations do you want to wait?";
cin >> gen;

int year = 0;

newpop = origpop;

do
{
newpop = newpop + .03;
newpop = newpop - .01;
year++;
} while ( year < gen );

cout << "If you start with" << origpop<< "and you wait for" << gen<< "generations, you'll end up with a total of" << newpop<< "of them.";
return 0;

thats what i have so far, but it doesnt work
First, here it is in [code][/code] tags:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
using namespace std;

int main()
{

int origpop, gen, newpop;
const int birth = origpop + .03
cout << "How many jackalopes do you have?";
cin >> origpop;
cout << "How many generations do you want to wait?";
cin >> gen;

int year = 0;

newpop = origpop;

do
{
newpop = newpop + .03;
newpop = newpop - .01;
year++;
} while ( year < gen );

cout << "If you start with" << origpop<< "and you wait for" << gen<< "generations, you'll end up with a total of" << newpop<< "of them.";
return 0;


Follow the program from top to bottom, as a computer would: Line 7 declares a variable, origpop. It is not defined at this point and its value is most likely random. Line 8 adds .03 to the undefined value and stores it in birth. Line 10 stores a user-entered value in origpop. These statements are not in the appropriate order.

Additionally, integers are signed whole numbers. You might want to use a float or double to store any value that should contain a decimal portion.

Hope this helps--I've got to run.
Topic archived. No new replies allowed.