Advertisement
Guest User

Untitled

a guest
Oct 12th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2.  
  3. public class HelloWorld
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         double capacity = double.Parse(Console.ReadLine());
  8.  
  9.         //След това до получаване на команда "End" или до запълване на багажника, се чете по един ред:
  10.         string volumeSuitcase = Console.ReadLine();
  11.         int count = 0;
  12.         double sum = 0;
  13.         double currSumVolume = 0;
  14.         while (volumeSuitcase != "End")
  15.         {
  16.             double volume = double.Parse(volumeSuitcase);
  17.  
  18.             if ((count + 1) % 3 == 0)
  19.             {
  20.                 volume = volume + volume * 0.1;
  21.             }
  22.             sum += volume;
  23.  
  24.             if (capacity < sum)
  25.             {
  26.                 break;
  27.             }
  28.             count++;
  29.             volumeSuitcase = Console.ReadLine();
  30.         }
  31.  
  32.  
  33.         if (volumeSuitcase == "End")
  34.         {
  35.             Console.WriteLine("Congratulations! All suitcases are loaded!");
  36.         }
  37.         if (sum > capacity)
  38.         {
  39.             Console.WriteLine("No more space!");
  40.         }
  41.  
  42.         Console.WriteLine($"Statistic: {count} suitcases loaded.");
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement