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