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