Advertisement
silvana1303

beehive population

May 22nd, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int population = int.Parse(Console.ReadLine());
  10.             int years = int.Parse(Console.ReadLine());
  11.  
  12.             for (int i = 1; i <= years; i++)
  13.             {
  14.                 int newBorn = population / 10 * 2;
  15.                 population += newBorn;
  16.  
  17.                 if (i % 5 == 0 )
  18.                 {
  19.                     int migrated = population / 50 * 5;
  20.                     population -= migrated;
  21.                 }
  22.  
  23.                 int dead = population / 20 * 2;
  24.                 population -= dead;
  25.             }
  26.  
  27.             Console.WriteLine($"Beehive population: {population}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement