Advertisement
spasnikolov131

Untitled

Jun 18th, 2022
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Linq.Expressions;
  3.  
  4. namespace Add_Bags
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int countEggs = int.Parse(Console.ReadLine());
  11. int totalEggs = 0;
  12. totalEggs += countEggs;
  13.  
  14. while (true)
  15. {
  16. string line = Console.ReadLine();
  17. int eggs = int.Parse(Console.ReadLine());
  18.  
  19. if (line == "Close")
  20. {
  21. Console.WriteLine("Store is closed!");
  22. Console.WriteLine($"{totalEggs} eggs sold.");
  23. break;
  24. }
  25. if (line == "Fill")
  26. {
  27. totalEggs += eggs;
  28. }
  29. if (eggs > totalEggs)
  30. {
  31. Console.WriteLine("Not enough eggs in store!");
  32. Console.WriteLine($"You can buy only {totalEggs}.");
  33. break;
  34. }
  35.  
  36. if (line == "Buy")
  37. {
  38. totalEggs -= eggs;
  39.  
  40. }
  41.  
  42. }
  43. }
  44. }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement