Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- int countEggs = int.Parse(Console.ReadLine());
- string comand = string.Empty;
- int EggsATM = 0;
- int counterSoldEggs = 0;
- while (countEggs > 0)
- {
- comand = Console.ReadLine();
- if (comand == "Close")
- {
- Console.WriteLine("Store is closed!");
- Console.WriteLine("{0} eggs sold.",counterSoldEggs);
- return;
- }
- else if (comand == "Buy")
- {
- EggsATM = int.Parse(Console.ReadLine());
- if (countEggs <= EggsATM)
- {
- int calc1 = EggsATM - countEggs;
- Console.WriteLine("Not enough eggs in store!");
- Console.WriteLine("You can buy only {0}.", countEggs);
- }
- countEggs = countEggs - EggsATM;
- counterSoldEggs += EggsATM;
- }
- else if (comand == "Fill")
- {
- EggsATM = int.Parse(Console.ReadLine());
- countEggs = countEggs + EggsATM;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement