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 _4.EasterShop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int easterEggs = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- int solddEggs = 0;
- int filledEggs = 0;
- int totalSoldEggs = 0;
- while (input!="Close")
- {
- if (input=="Buy")
- {
- solddEggs = int.Parse(Console.ReadLine());
- if (solddEggs > easterEggs)
- {
- Console.WriteLine($"Not enough eggs in store!");
- Console.WriteLine($"You can buy only {easterEggs}.");
- return;
- }
- else if (solddEggs <= easterEggs)
- {
- easterEggs -= solddEggs;
- totalSoldEggs += solddEggs;
- }
- }
- else if(input=="Fill")
- {
- filledEggs = int.Parse(Console.ReadLine());
- easterEggs += filledEggs;
- }
- input = Console.ReadLine();
- }
- Console.WriteLine($"Store is closed!");
- Console.WriteLine($"{totalSoldEggs} eggs sold.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement