Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _4.Easter_Shop
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. int numberEggs = int.Parse(Console.ReadLine());
  11. string zaqvka = string.Empty;
  12. int eggs = 0;
  13. int sum = 0;
  14.  
  15.  
  16.  
  17.  
  18. while (zaqvka != "Close")
  19. {
  20. zaqvka = Console.ReadLine();
  21. eggs = int.Parse(Console.ReadLine());
  22.  
  23.  
  24. if (zaqvka == "Buy")
  25. {
  26. if (numberEggs < eggs)
  27. {
  28. Console.WriteLine("Not enough eggs in store!");
  29. Console.WriteLine($"You can buy only {numberEggs}.");
  30. }
  31.  
  32. numberEggs -= eggs;
  33. sum = sum + eggs;
  34. }
  35. if (zaqvka == "Fill")
  36. {
  37. numberEggs += eggs;
  38. }
  39.  
  40.  
  41. if (zaqvka == "Close")
  42. {
  43. break;
  44. }
  45. Console.WriteLine("Store is closed!");
  46. Console.WriteLine($"{sum} eggs sold.");
  47. }
  48.  
  49.  
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement