I'm doing a program for my class, Here's the objective:
Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of organisms, their average daily population increase (as a percent), and the number of days they will multiply. A loop should display the size of the population each day.
I can't seem to figure out how to make the variable "new_population" change after every day; it remains constant. Can anyone help?
Follow the logic. Look at the code and ask yourself "what is the computer going to do here?".
Take a look at this:
1 2 3 4 5 6 7 8 9
// here you set new_population
new_population = new_population_percentage + start_num;
// then after that, you loop 'num_days' times
for(int x = 1; x <= num_days; x++)
{
cout << x << "\t\t" << new_population << endl; // but in your loop all you do is print the same
// new_population over and over again
}
If you want new_population to change each time that loop runs, then you need to change it inside the loop.