Advertisement
Guest User

Untitled

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