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 availableEggs = int.Parse(Console.ReadLine());
- int soldEggs = 0;
- string input = Console.ReadLine();
- while (input != "Close")
- {
- int eggs = int.Parse(Console.ReadLine());
- if (input == "Buy")
- {
- if (availableEggs - eggs < 0)
- {
- break;
- }
- availableEggs -= eggs;
- soldEggs += eggs;
- }
- else if (input == "Fill")
- {
- availableEggs += eggs;
- }
- input = Console.ReadLine();
- }
- if (input == "Close")
- {
- Console.WriteLine("Store is closed!");
- Console.WriteLine($"{ soldEggs} eggs sold.");
- }
- else
- {
- Console.WriteLine("Not enough eggs in store!");
- Console.WriteLine($"You can buy only {availableEggs}.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment