Advertisement
Guest User

Untitled

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