Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- int eggs = int.Parse(Console.ReadLine());
- int eggsSold = 0;
- while(true)
- {
- string command = Console.ReadLine();
- if (command == "Close")
- {
- Console.WriteLine("Store is closed!");
- Console.WriteLine($"{eggsSold} eggs sold.");
- break;
- }
- int moreEggs = int.Parse(Console.ReadLine());
- if (command == "Buy")
- {
- if (eggs < moreEggs)
- {
- Console.WriteLine("Not enough eggs is store!");
- Console.WriteLine($"You can buy only {eggs}.");
- break;
- }
- eggs -= moreEggs;
- eggsSold += moreEggs;
- }
- else if (command == "Fill")
- {
- eggs += moreEggs;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement