Advertisement
Locoluis

MEXICO.PAS for Turbo Pascal

Oct 18th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.50 KB | None | 0 0
  1. program Mexico;
  2.  
  3. const
  4.     x0 = 58000000;
  5.     xf = 100000000;
  6.     t0 = 1994;
  7.     rate = 0.07;
  8.  
  9. function expPop(t: Real): Longint;
  10. begin
  11.     expPop := Round(x0 * Exp( t * Ln( 1 + rate ) ));
  12. end;
  13.  
  14. var
  15.     x: Longint;
  16.     t: Longint;
  17.     tf: Real;
  18. begin
  19.     t := 0;
  20.     x := x0;
  21.     repeat
  22.         Writeln('Year: ', (t + t0), '; Population: ', x);
  23.         t := t + 1;
  24.         x := expPop(t);
  25.     until x >= xf;
  26.     tf := ( Ln(xf) - Ln(x0) ) / Ln ( 1 + rate);
  27.     x := expPop(tf);
  28.     Writeln('Year: ', (tf + t0), '; Population: ', x);
  29.     Readln;
  30. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement