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