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