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