//OrinTill Qimid CS1A Chapter 4, P. 294, 4
//
/**************************************************************
 * CALCULATE ANNUAL POPULATION
 * 
 * ____________________________________________________________
 * This program will calculate the annual population per year.
 * ____________________________________________________________
 * INPUT
 * population : starting pupolation
 * birth : birth rate
 * death : death rate;
 * years : the number of years
 * OUTPUT
 * newyear : new population
 **************************************************************/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
float newyear();


int main() 
{
  
newyear();
return 0;
   
}
float newyear()
{
    
    // N = P + BP - DP
    float newyear,
    population,
    birth,
    death,
    years;
    cout<<"How many years do you want to calculate?"<<endl;
    cin>>years;
    while (years<0)
    {
       cout<<"please enter a vaild number"<<endl;
       cin>> years;
    }
    cout<<"whats the starting population?"<<endl;
    cin>>population;
    while (population<2)
    {
       cout<<"please enter a vaild number"<<endl;
       cin>> population;
    }
    cout<<"whats the birth rate?"<<endl;
    cin>> birth;
    while (birth<0)
    {
       cout<<"please enter a vaild number"<<endl;
       cin>> birth;
    }
    cout<<"whats the death rate?"<<endl;
    cin>> death;
    while (death<0)
    {
       cout<<"please enter a vaild number"<<endl;
       cin>> death;
    }
    for (int i = 1; i <= years; i++)
    {
        birth=(birth/100)*population;
        death=(death/100)*population;
         newyear = population + birth - death;
         population = newyear;
         cout<<"the population in year "<<i<<" is "<<newyear<<endl;
    }
    return newyear;
    
    

}