Advertisement
silvana1303

suitcases load

May 2nd, 2020
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double capacity = double.Parse(Console.ReadLine());
  10.             var command = Console.ReadLine();
  11.             int count = 0;
  12.  
  13.             while (command != "End")
  14.             {
  15.  
  16.                 double suitcase = double.Parse(command);
  17.  
  18.                 count++;
  19.  
  20.                 if (count % 3 == 0)
  21.                 {
  22.                     suitcase *= 1.10;
  23.                 }
  24.  
  25.  
  26.                 if (capacity <= suitcase)
  27.                 {
  28.                     count--;
  29.                     break;
  30.                    
  31.                 }
  32.  
  33.  
  34.                 capacity -= suitcase;
  35.  
  36.                 command = Console.ReadLine();
  37.             }
  38.  
  39.             if (command == "End")
  40.             {
  41.                 Console.WriteLine("Congratulations! All suitcases are loaded!");
  42.             }
  43.             else
  44.             {
  45.                 Console.WriteLine("No more space!");
  46.             }
  47.  
  48.             Console.WriteLine($"Statistic: {count} suitcases loaded.");
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement