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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
double new_pop(double, double, double, double, double, double, double, int);
int main()
{
double start_pop = 0, annual_birth_rate = 0, annual_death_rate = 0, number_of_years = 0,
new_population = 0, current_pop = 0, annual_birth_rate2 = 0,
annual_death_rate2, annual_birth_rate3, population_growth, population;
int A;
cout << "What's the starting size of the population? (Minimum of 2) " << endl;
cin >> start_pop;
if (start_pop >= 2 && start_pop <= 10000);
else if (cout << "Are you some type of self reproducing creature? If not, try again." << endl)
return 0;
cout << "What's the annual birth rate? (Enter 1-1000)" << endl;
cin >> annual_birth_rate;
if (annual_birth_rate >= 1 && annual_birth_rate <= 1000);
else if (cout << "Isn't anyone procreating?? If so, try again." << endl)
return 0;
annual_birth_rate2 = annual_birth_rate / 1000;
cout << "What's the annual death rate? (Enter 1-1000)" << endl;
cin >> annual_death_rate;
if (annual_death_rate >= 1 && start_pop <= 1000);
else if (cout << "Is your society immortal?? If not, try again." << endl)
return 0;
annual_death_rate2 = annual_death_rate / 1000;
current_pop = annual_birth_rate - annual_death_rate + start_pop;
cout << "Your current population is " << current_pop << " in our society." << endl;
cout << "Enter the amount of years you'd like to see the population growth. " << endl;
cin >> number_of_years;
cout << "The estimated growth in " << A << " years is " << annual_birth_rate3 << "." << endl;
return 0;
}
double new_pop(double population_growth, double annual_birth_rate, double annual_death_rate,double population, double current_pop, double number_of_years, double annual_birth_rate3, int A)
{
population_growth = annual_birth_rate - annual_death_rate;
population = current_pop + population_growth;
for (A = 1; A <= number_of_years; ++A)
{
annual_birth_rate3 = A * population_growth + current_pop;
}
return main();
}
|