tsvetelinapasheva

LoadSuitcases

Feb 23rd, 2021 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp37
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double trunkCapacity = double.Parse(Console.ReadLine());
  10.             string command = Console.ReadLine();
  11.             double suitcaseCount = 0;
  12.             double totalVolume = 0;
  13.            
  14.             while (command != "End")
  15.             {
  16.                 double suitcaseVolume = double.Parse(command);
  17.                 suitcaseCount++;
  18.                 if (suitcaseCount % 3 == 0)
  19.                 {
  20.                     suitcaseVolume += suitcaseVolume * 0.10;
  21.                 }
  22.                 totalVolume += suitcaseVolume;
  23.  
  24.                 if (totalVolume > trunkCapacity)
  25.                 {
  26.                     Console.WriteLine("No more space!");
  27.                     suitcaseCount--;
  28.                     break;
  29.                 }
  30.  
  31.                 command = Console.ReadLine();
  32.             }
  33.  
  34.             if (command == "End")
  35.             {
  36.                 Console.WriteLine("Congratulations! All suitcases are loaded!");
  37.             }
  38.  
  39.             Console.WriteLine($"Statistic: {suitcaseCount} suitcases loaded.");
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment