ralichka

Exam-10.03.2019-01.HuntingGames

Nov 1st, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01.TheHuntingGames
  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 groupEnergy = double.Parse(Console.ReadLine());
  12.             double waterPerDay = double.Parse(Console.ReadLine());
  13.             double foodPerDay = double.Parse(Console.ReadLine());
  14.  
  15.             double totalWater = waterPerDay * players*days;
  16.             double totalFood = foodPerDay * players*days;
  17.  
  18.             for (int i = 1; i <= days; i++)
  19.             {
  20.                 double energyLoss = double.Parse(Console.ReadLine());
  21.                 if (groupEnergy <= 0)
  22.                 {
  23.                     return;
  24.                 }
  25.                 if (groupEnergy - energyLoss <= 0)
  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.                 else
  31.                 {
  32.                     groupEnergy -= energyLoss;
  33.  
  34.                     if (i % 2 == 0)
  35.                     {
  36.                         groupEnergy *= 1.05;
  37.                         totalWater *= 0.7;
  38.                     }
  39.                     if (i % 3 == 0)
  40.                     {
  41.                         totalFood -= totalFood / players;
  42.                         groupEnergy *= 1.1;
  43.                     }
  44.                 }
  45.             }
  46.             Console.WriteLine($"You are ready for the quest. You will be left with - {groupEnergy:f2} energy!");
  47.            
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment