Advertisement
alexbancheva

Seize_the_Fire_MidExam_10thOfMarch2019

Apr 13th, 2020
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Seize_the_Fire_MidExam_10thOfMarch2019
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var fireCells = Console.ReadLine()
  12.                 .Split("#").ToArray();
  13.  
  14.             double water = double.Parse(Console.ReadLine());
  15.             double totalFire = 0;
  16.             double effortsTotal = 0;
  17.  
  18.             bool isValid = false;
  19.             var cells = new List<double>();
  20.  
  21.             for (int i = 0; i < fireCells.Length; i++)
  22.             {
  23.                 var item = fireCells[i].Split(" = ");
  24.                 string typeOfFire = item[0];
  25.                 double value = int.Parse(item[1]);
  26.  
  27.                 if (typeOfFire == "High")
  28.                 {
  29.                     if (value <= 125 && value >= 81)
  30.                     {
  31.                         isValid = true;
  32.                         cells.Add(value);
  33.                     }
  34.                 }
  35.                 else if (typeOfFire == "Medium")
  36.                 {
  37.                     if (value <= 80 && value >= 51)
  38.                     {
  39.                         isValid = true;
  40.                         cells.Add(value);
  41.                     }
  42.                 }
  43.                 else if (typeOfFire == "Low")
  44.                 {
  45.                     if (value <= 50 && value >= 1)
  46.                     {
  47.                         isValid = true;
  48.                         cells.Add(value);
  49.                     }
  50.                 }
  51.                 else
  52.                 {
  53.                     isValid = false;
  54.                     continue;
  55.                 }
  56.  
  57.                 if (isValid)
  58.                 {
  59.                     water -= value;
  60.                     totalFire += value;
  61.                    
  62.                 }
  63.                
  64.                 double efforts = value * 0.25;
  65.                 effortsTotal += efforts;
  66.             }
  67.  
  68.             Console.WriteLine("Cells:");
  69.  
  70.             //foreach (var cell in cells)
  71.             //{
  72.             //    Console.WriteLine($"- {cell}");
  73.             //}
  74.  
  75.             for (int i = 0; i < cells.Count; i++)
  76.             {
  77.                 Console.WriteLine($"- {cells[i]}");
  78.             }
  79.  
  80.             Console.WriteLine($"Efforts: {effortsTotal:f2}");
  81.             Console.WriteLine($"Total Fire: {totalFire}");
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement