Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class SumOfnNumbers
- {
- static void Main()
- {
- double daysOfAdventure = double.Parse(Console.ReadLine());
- double countOfPlayers = double.Parse(Console.ReadLine());
- double groupsEnergy = double.Parse(Console.ReadLine());
- double waterPerday = double.Parse(Console.ReadLine());
- double foodPerDay = double.Parse(Console.ReadLine());
- double totalWater = daysOfAdventure * countOfPlayers * waterPerday;
- double totalFood = daysOfAdventure * countOfPlayers * foodPerDay;
- for (int i = 1; i <= daysOfAdventure; i++)
- {
- double energyLoss = double.Parse(Console.ReadLine());
- groupsEnergy -= energyLoss;
- if (i % 2 == 0)
- {
- double energyBoost = groupsEnergy * 0.05;
- groupsEnergy += energyBoost;
- double waterReduction = totalWater * 0.30;
- totalWater -= waterReduction;
- }
- if (i % 3 == 0)
- {
- double energyBoost = groupsEnergy * 0.10;
- groupsEnergy += energyBoost;
- double FoodReduction = totalFood / countOfPlayers;
- totalFood -= FoodReduction;
- }
- }
- if (groupsEnergy > 0)
- {
- Console.WriteLine($"You are ready for the quest. You will be left with - {groupsEnergy:F2} energy!");
- }
- else
- {
- Console.WriteLine($"You will run out of energy. You will be left with {totalFood:F2} food and {totalWater:F2} water.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement