Anzzhhela98

ff

Jul 12th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Товарен_багаж
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double capacity = double.Parse(Console.ReadLine());
  10.             double countLuggage = 0;
  11.             double allSpace = 0;
  12.             while (capacity > 0)
  13.             {
  14.                 string command = Console.ReadLine();
  15.                 if (command == "End")
  16.                 {
  17.                     Console.WriteLine("Congratulations! All suitcases are loaded!");
  18.                     break;
  19.                 }
  20.                 double volumeSuitCase = double.Parse(command);
  21.  
  22.                 countLuggage++;
  23.                 allSpace += volumeSuitCase;
  24.                
  25.  
  26.                 if (capacity < allSpace)
  27.                 {
  28.                     Console.WriteLine("No more space!");
  29.                     countLuggage--;
  30.                     break;
  31.                 }
  32.                 if (countLuggage % 3 == 0)
  33.                 {
  34.                     allSpace = (allSpace * 0.1) + allSpace;
  35.                 }
  36.  
  37.  
  38.             }
  39.             Console.WriteLine($"Statistic: {countLuggage} suitcases loaded."
  40. );
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment