Advertisement
Guest User

Untitled

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