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