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