Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. int eggs = int.Parse(Console.ReadLine());
  4. int eggsSold = 0;
  5.  
  6. while(true)
  7. {
  8. string command = Console.ReadLine();
  9.  
  10. if (command == "Close")
  11. {
  12. Console.WriteLine("Store is closed!");
  13. Console.WriteLine($"{eggsSold} eggs sold.");
  14. break;
  15. }
  16.  
  17. int moreEggs = int.Parse(Console.ReadLine());
  18.  
  19. if (command == "Buy")
  20. {
  21. if (eggs < moreEggs)
  22. {
  23. Console.WriteLine("Not enough eggs is store!");
  24. Console.WriteLine($"You can buy only {eggs}.");
  25. break;
  26. }
  27.  
  28. eggs -= moreEggs;
  29. eggsSold += moreEggs;
  30. }
  31. else if (command == "Fill")
  32. {
  33. eggs += moreEggs;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement