Guest User

Untitled

a guest
Apr 20th, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. string comand = string.Empty;
  18. int EggsATM = 0;
  19.  
  20. int counterSoldEggs = 0;
  21.  
  22. while (true)
  23. {
  24. comand = Console.ReadLine();
  25. if (comand == "Close")
  26. {
  27. Console.WriteLine("Store is closed!");
  28. Console.WriteLine("{0} eggs sold.",counterSoldEggs);
  29. break;
  30. }
  31. else if (comand == "Buy")
  32. {
  33. int buy_egg = int.Parse(Console.ReadLine());
  34. if ( ( countEggs - buy_egg) < 0 ){
  35. Console.WriteLine("Not enough eggs in store!");
  36. Console.WriteLine("You can buy only {0}.", countEggs);
  37. continue;
  38. }else{
  39. countEggs -= buy_egg;
  40. counterSoldEggs += buy_egg;
  41. }
  42. }
  43. else if (comand == "Fill"){
  44. int fill_egs = int.Parse(Console.ReadLine());
  45. countEggs += fill_egs;
  46. }
  47. else{
  48. Console.WriteLine(" Incorrect command");
  49. }
  50. }
  51. }
  52. }
  53. }
RAW Paste Data