Write a program that illustrates the growth of the world's population using as input:
the start year
the initial population size
the annual percentage increase of the population
the end year.
You may assume that the input is valid.
Output the year, the size of the population and the population density every decade:
Surface area of a sphere is 4*π* R2
Earth’s radius [R] =3,984 miles
Fraction of surface which is land [F] = 0.29
π = PI = 3.14159
Use the total surface area of the earth (from given values for the Earth’s radius [R]) and the fraction
of the earth's surface which is land [F] to compute the land area. Specify the language used.
Initial Algorithm
CONSTANTS earth’s radius, PI, fraction of surface which is land
DECLARE necessary variables
CALCULATE the land area
INPUT the start year and the start population size
INPUT the annual percentage increase of the population
INPUT the end year
CALCULATE the annual growth rate
CALCULATE the number of decades (rounded up to the next highest integer)
CALCULATE initial population density {the initial population / land area}
PRINT headings
PRINT start year, initial population, initial population density
SET working population to the initial population size
FOR count = 1 TO number of decades DO
FOR inner count = 1 to 10 DO
CALCULATE the next working population {working population * growth
rate}
END FOR
CALCULATE the population density
UPDATE current year
PRINT current year, the working population and the population density
END FOR
-----------------below is the code i have done without errors i am stucj at the loop section----- please modify------------------
#include <iostream>
using namespace std;
int main()
{
double R=3984;
double PI=3.14159;
double F=0.29;
int start_year,end_year;
double an_pop_growth;
double start_pop_size;
cout <<" Welcome to the population growth calculation" <<endl;
cout <<"please enter start year: "<<endl;
cin>>start_year;
cout <<"please enter start population size: "<<endl;
cin>>start_pop_size;
cout <<" please enter end year: "<<endl;
cin>>end_year;
cout<<"please enter the annual percentage of population growth: "<<endl;
cin>>an_pop_growth;
double land_area=(4*PI*R*R)*0.29;
cout <<"land area of earth is: " <<land_area<<endl;
double an_growth_rate=an_pop_growth*start_pop_size;
cout<<"annual growth of population is: "<<an_growth_rate<<endl;
int num_decade=(end_year-start_year)/10;
double ini_pop_density=start_pop_size/land_area;
cout<<"Initial population density is : " <<ini_pop_density<<endl;
system("pause");
return 0;
}