petaryankov00

Suitcases

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