Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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___2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numberOfEggs = int.Parse(Console.ReadLine());
  14. int soldEggs = 0;
  15.  
  16. while (true)
  17. {
  18. string command = Console.ReadLine();
  19.  
  20. if (command == "Close")
  21. {
  22. Console.WriteLine("Store is closed!");
  23. Console.WriteLine(soldEggs + " eggs sold.");
  24. break;
  25. }
  26.  
  27. int fillOrBuyNumberOfEggs = int.Parse(Console.ReadLine());
  28.  
  29.  
  30. if (command == "Buy" && fillOrBuyNumberOfEggs > numberOfEggs)
  31. {
  32. Console.WriteLine("Not enough eggs in store!");
  33. Console.WriteLine("You can buy only " + numberOfEggs + ".");
  34. break;
  35. }
  36. else
  37. {
  38. if (command == "Buy")
  39. {
  40. numberOfEggs -= fillOrBuyNumberOfEggs;
  41. soldEggs += fillOrBuyNumberOfEggs;
  42. }
  43. else if (command == "Fill")
  44. {
  45. numberOfEggs += fillOrBuyNumberOfEggs;
  46. }
  47. }
  48.  
  49.  
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement