In a population, the birth rate is the percentage increase of the population due
ID: 3552790 • Letter: I
Question
In a population, the birth rate is the percentage increase of the population due to births, and the death rate is the percentage decrease of the population due to deaths. Write a program that asks for the following:
The program should then display the starting population and the projected population at the end of each year. It should use a function that calculates and returns the projected new size of the population after a year. The formula is
N = P(1 + B)(1 - D)
where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate. Annual birth rate and death rate are the typical number of births and deaths in a year per 1000 people, expressed as a decimal. So, for example, if there are normally about 32 births and 26 deaths per 1000 people in a given population, the birth rate would be .032 and the death rate would be .026.
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
long int popul,newpopul,yrs,count=0;
float birth_rate, death_rate;
cout<<"Enter starting size : ";
cin>>popul;
cout<<endl<<"Enter annual birth rate : ";
cin>>birth_rate;
cout<<endl<<"Enter annual death rate : ";
cin>>death_rate;
cout<<endl<<"Enter years to display : ";
cin>>yrs;
cout<<endl;
count=1;
while(yrs)
{
newpopul=popul*(1+birth_rate)*(1-death_rate); //formula to calculate newpopulation
cout<<endl<<"After "<<count<<" years"<<endl;
cout<<"Starting population : "<<popul<<" Projected population :"<<newpopul<<endl;
count=count+1; // counting years for output
popul=newpopul; //placing the value of calculated new population to
//popul value for upcoming years
yrs=yrs-1; //decreasing the number of years by 1
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.