sanyakasarova

05. Suitcases Load

Jun 19th, 2021 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _2._Exam_Preparation
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double trunkVolume = double.Parse(Console.ReadLine());
  10.  
  11. int suitcaseCounter = 0;
  12.  
  13. string input = Console.ReadLine();
  14.  
  15. while (input != "End")
  16. {
  17. double currentSuitcaseVolume = double.Parse(input);
  18.  
  19. suitcaseCounter++;
  20.  
  21. if (suitcaseCounter % 3 == 0)
  22. {
  23. currentSuitcaseVolume += currentSuitcaseVolume * 0.10;
  24. }
  25.  
  26. if (trunkVolume < currentSuitcaseVolume)
  27. {
  28. Console.WriteLine("No more space!");
  29. suitcaseCounter--;
  30. break;
  31. }
  32.  
  33. trunkVolume -= currentSuitcaseVolume;
  34.  
  35. input = Console.ReadLine();
  36. }
  37.  
  38. if (input == "End")
  39. {
  40. Console.WriteLine("Congratulations! All suitcases are loaded!");
  41. }
  42.  
  43. Console.WriteLine($"Statistic: {suitcaseCounter} suitcases loaded.");
  44. }
  45. }
  46. }
  47.  
Add Comment
Please, Sign In to add comment