Advertisement
silvana1303

the hunting games

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