title: Conditions and for loop in C#
body: <p>I am new to C# and I am trying to solve a population algorithm.</p>
  
  <p>These are the conditions:</p>
  
  <ul>
  <li>the starting population is 26000</li>
  <li>Influx of people each year is set in a variable</li>
  <li>Emigrated people each year is set in a variable</li>
  <li>Born each year are 0.7% of the population</li>
  <li>Deceased year are 0.8% of the population</li>
  </ul>
  
  <p>The user provides the year when this algorithm ends.</p>
  
  <ol>
  <li>Then there a summary should state if there is a increase of decrease that has occurred and the number of either increased or decreased.</li>
  <li>Each line should then show the year and the population for that year until the end year provided by the user.</li>
  </ol>
  
  <p>In my code I have set the end year to 2030 from readline and influx variable to 300, and emigrated variable to 325. But depending on these values, there could either be a increase or decrease each year, this value is static for each year.</p>
  
  <p>Below is my code: </p>
  
  <pre><code>using System;
  
  namespace algoritmer.loopsFor
  {
      public class Övn38
      {
  
          int Population = 26000;
          int TotalPopulation;
          int influx = 300;
          int emigrated = 325;
  
          public void CalcPopulation(int endYear)
          {
              int born = (int)(0.007 * Population);
              int deceased = (int)(0.006 * Population);
              Population = influx - emigrated + born + deceased;
  
              if (Population &gt; 0)
              {
                  Console.WriteLine($"Current Population increases each year  by: {Population}");
              }
              else
                  Console.WriteLine($"Current Population decreases each year by: {Population}");
  
              Console.WriteLine("__________________________________________");
  
              for (int startYear = 2019+1; startYear &lt;= endYear; startYear++)
              {
                  Population = Population + influx - emigrated + born - deceased;
                  TotalPopulation = Population + Population;
                  Console.WriteLine($"Population for year {startYear} is: {TotalPopulation}");
                  Console.WriteLine();
              }
  
              Console.WriteLine("__________________________________________");
          }
  
          public void printCalcPopulation()
          {
              Console.WriteLine($"Population is: {Population}");
              Console.WriteLine("Write the end year");
              int year = int.Parse(Console.ReadLine());
              Console.WriteLine("__________________________________________");
              CalcPopulation(year);
          }
      }
  }
  </code></pre>
  
  <p>But I know my algorithm is wrong. As the image include shows my output:</p>
  
  <p><a href="https://i.stack.imgur.com/9MPpt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9MPpt.png" alt="enter image description here"></a></p>
  
  <p>Thanks</p>