Krasimir_Slavov

Untitled

Mar 11th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EAXAM_The_Hunting_Games
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             int players = int.Parse(Console.ReadLine());
  11.             double energy = double.Parse(Console.ReadLine());
  12.             double water = double.Parse(Console.ReadLine());
  13.             double food = double.Parse(Console.ReadLine());
  14.             double energyLoss = double.Parse(Console.ReadLine());
  15.  
  16.             double currEnergy = 0;
  17.             double currWater = 0;
  18.             double currFood = 0;
  19.  
  20.             double totalWater = days * players * water;
  21.             double totalFood = days * players * food;
  22.  
  23.  
  24.             if (energy <= 0) return;
  25.  
  26.             for (int currDay = 1; currDay <= days; currDay++)
  27.             {
  28.                 currEnergy = energy - energyLoss;
  29.                 if (currDay % 2 == 0)
  30.                 {
  31.                     currEnergy = totalWater - currEnergy * 0.05;
  32.                     currWater -= currWater * 0.30;
  33.                 }
  34.                 if (currDay % 3 == 0)
  35.                 {
  36.                     currFood -= currFood / players;
  37.                     currEnergy += currEnergy * 0.10;
  38.                 }
  39.                
  40.             }
  41.             if (currEnergy > energy)
  42.             {
  43.                 Console.WriteLine($"You are ready for the quest. You will be left with - {currEnergy} energy!");
  44.             }
  45.             else
  46.             {
  47.                 Console.WriteLine($"You will run out of energy. You will be left with {currFood:F2} food and {currWater:F2} water.");
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment