Programming Help

There is a lake with 3 different types of fishes living in it: “red”, “green” and “blue”. In the beginning of the first year 50% of fishes were “red”, 40% of fishes were “green” and 10% of fishes were “blue”.

I receive, from user, three numbers stating the growth rates for each type of fishes. Then I receive from user one more number stating the number of years passed from the “initial state”.

I got to calculate and output the percentage of each fish population in the lake after the number of years specified by user will pass.

All the growth rates got to be not less than 0. If user inputs something wrong make him reenter the value until the value is entered correctly. The number of years entered is not less than zero.

compute percentages for each year based on the results received for previous year

Normalize all the values.
Well what do you have so far
I got nothing so far man. I don't even know how to get started.
Well nobody here is going to do it for you but we can help.

What I would do to make it easier is make 3 variables for each type of fish and base it on 100 total fish (20 red 40 green 40 blue). Then ask the user what the growth rate is for each fish and store those in seperate variables.

Then you can calculate (there is a growth rate forumla I just cant think of it right now) and plug the variables into it and then output the results
Thanks a lot man...i appreciate it.
No problem, once you start it and have some code and your stuck we will go more indepth with it
so I have a similar problem and I have this so far...

#include <iostream>
using namespace std;

int main()
{

int red, blue, green, initial_state;


cout << "Please enter three numbers:" << endl;
cin >> red >> blue >> green; //growth rate of the three fishes

cout << "Please enter the number of years" << endl;
cin >> initial_state;

while (initial_state <=0)
{
red= initial_state*(50/100);

cout << "The growth rate of the red fish is" << red << endl;

blue = initial_state * (10/100);

cout << "The growth rate of the blue fish is" << blue << endl;

green= initial_state*(40/100);

cout << "The growth rate of the green fish is" << green << endl;

}

return 0;

}





It doesn't work because I don't think I did the calculations yet but I don't even know what else to do and idk if I'm doing this correctly...
help please :(
Last edited on
while (initial_state <=0)

The initial_state is holding the number of years the user entered. This should be greater than or equal to zero before you go ahead with calculations. If it's less than zero, the assignment wants you to prompt the user to re-enter. There are a few values that shouldn't be less than zero, so you might consider making a separate validate function that checks for numbers less than zero.


1
2
3
4
cin >> red >> blue >> green; //growth rate of the three fishes
red= initial_state*(50/100);
blue = initial_state * (10/100);
green= initial_state*(40/100);


The user enters three values for growth rates, then the code overwrites those values with the number of years multiplied by the initial population percentage. I don't think that's what you meant to do?


There's a population growth formula here that might help. (Change in population over time divided by original population)
http://en.wikipedia.org/wiki/Population_growth
Topic archived. No new replies allowed.