Anzzhhela98

фф

Jul 12th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 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.                 if (capacity < allSpace)
  25.                 {
  26.                     Console.WriteLine("No more space!");
  27.                     countLuggage--;
  28.                     break;
  29.                 }
  30.  
  31.             }
  32.             Console.WriteLine($"Statistic: {countLuggage} suitcases loaded."
  33. );
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment