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