elena1234

TheHuntingGames

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