Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2.  
  3. class SumOfnNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         double daysOfAdventure = double.Parse(Console.ReadLine());
  8.         double countOfPlayers = double.Parse(Console.ReadLine());
  9.         double groupsEnergy = double.Parse(Console.ReadLine());
  10.         double waterPerday = double.Parse(Console.ReadLine());
  11.         double foodPerDay = double.Parse(Console.ReadLine());
  12.  
  13.         double totalWater = daysOfAdventure * countOfPlayers * waterPerday;
  14.         double totalFood = daysOfAdventure * countOfPlayers * foodPerDay;
  15.         for (int i = 1; i <= daysOfAdventure; i++)
  16.         {
  17.             double energyLoss = double.Parse(Console.ReadLine());
  18.             groupsEnergy -= energyLoss;
  19.             if (i % 2 == 0)
  20.             {
  21.                 double energyBoost = groupsEnergy * 0.05;
  22.                 groupsEnergy += energyBoost;
  23.                 double waterReduction = totalWater * 0.30;
  24.                 totalWater -= waterReduction;
  25.             }
  26.             if (i % 3 == 0)
  27.             {
  28.                 double energyBoost = groupsEnergy * 0.10;
  29.                 groupsEnergy += energyBoost;
  30.                 double FoodReduction = totalFood / countOfPlayers;
  31.                 totalFood -= FoodReduction;
  32.             }
  33.            
  34.         }
  35.         if (groupsEnergy > 0)
  36.         {
  37.             Console.WriteLine($"You are ready for the quest. You will be left with - {groupsEnergy:F2} energy!");
  38.         }
  39.         else
  40.         {
  41.             Console.WriteLine($"You will run out of energy. You will be left with {totalFood:F2} food and {totalWater:F2} water.");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement