Advertisement
silvana1303

beehive defence

May 22nd, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 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 swarm = int.Parse(Console.ReadLine());
  10.             int healthBear = int.Parse(Console.ReadLine());
  11.             int attackBear = int.Parse(Console.ReadLine());
  12.  
  13.             while (swarm > 0)
  14.             {
  15.                 swarm -= attackBear;
  16.                 healthBear -= swarm * 5;
  17.  
  18.                 if (swarm < 100 && swarm >= 0)
  19.                 {
  20.                     Console.WriteLine($"The bear stole the honey! Bees left {swarm}.");
  21.                     break;
  22.                 }
  23.  
  24.                 if (swarm < 0)
  25.                 {
  26.                     swarm = 0;
  27.                     Console.WriteLine($"The bear stole the honey! Bees left {swarm}.");
  28.                     break;
  29.                 }
  30.  
  31.                 if (healthBear <= 0)
  32.                 {
  33.                     Console.WriteLine($"Beehive won! Bees left {swarm}.");
  34.                     break;
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement