Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9.  
  10. namespace Rextester
  11. {
  12. public class Program
  13. {
  14. public static void Main(string[] args)
  15. {
  16. int countEggs = int.Parse(Console.ReadLine());
  17.  
  18. string comand = string.Empty;
  19.  
  20. int EggsATM = 0;
  21.  
  22. int counterSoldEggs = 0;
  23.  
  24. while (countEggs > 0)
  25. {
  26. comand = Console.ReadLine();
  27. if (comand == "Close")
  28. {
  29. Console.WriteLine("Store is closed!");
  30. Console.WriteLine("{0} eggs sold.",counterSoldEggs);
  31. return;
  32. }
  33. else if (comand == "Buy")
  34. {
  35. EggsATM = int.Parse(Console.ReadLine());
  36. if (countEggs <= EggsATM)
  37. {
  38. int calc1 = EggsATM - countEggs;
  39. Console.WriteLine("Not enough eggs in store!");
  40. Console.WriteLine("You can buy only {0}.", countEggs);
  41. }
  42. countEggs = countEggs - EggsATM;
  43. counterSoldEggs += EggsATM;
  44. }
  45. else if (comand == "Fill")
  46. {
  47. EggsATM = int.Parse(Console.ReadLine());
  48. countEggs = countEggs + EggsATM;
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement