Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.Easter_Shop___2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfEggs = 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 fillOrBuyNumberOfEggs = int.Parse(Console.ReadLine());
- if (command == "Buy" && fillOrBuyNumberOfEggs > numberOfEggs)
- {
- Console.WriteLine("Not enough eggs in store!");
- Console.WriteLine("You can buy only " + numberOfEggs + ".");
- break;
- }
- else
- {
- if (command == "Buy")
- {
- numberOfEggs -= fillOrBuyNumberOfEggs;
- soldEggs += fillOrBuyNumberOfEggs;
- }
- else if (command == "Fill")
- {
- numberOfEggs += fillOrBuyNumberOfEggs;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement