% mexico_population_until.m
%  Model Mexico population UNTIL it exceeds a given target.
%
%  Year  Population
%  1950  25,791,017
%  1960  34,923,129
%  1970  48,225,238
%  1980  66,846,833
%  1990  81,249,645
%  2000  97,483,412
%  2010 113,580,528
%
rate = input ( '  Enter model growth rate, like 0.03: ' );
target = input ( '  Enter target population size to reach: ' );
year = 1950;

while ( true )

  if ( year == 1950 )
    pop = 25791017;
  else
    pop_old = pop;
    pop = ( 1.0 + rate ) * pop_old;
  end
  fprintf ( '  %d  %.0f\n', year, pop )

  if ( target <= pop )
    break;
  end

  year = year + 1;

end
    
