Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- int countEggs = int.Parse(Console.ReadLine());
- string comand = string.Empty;
- int EggsATM = 0;
- int counterSoldEggs = 0;
- while (true)
- {
- comand = Console.ReadLine();
- if (comand == "Close")
- {
- Console.WriteLine("Store is closed!");
- Console.WriteLine("{0} eggs sold.",counterSoldEggs);
- break;
- }
- else if (comand == "Buy")
- {
- int buy_egg = int.Parse(Console.ReadLine());
- if ( ( countEggs - buy_egg) < 0 ){
- Console.WriteLine("Not enough eggs in store!");
- Console.WriteLine("You can buy only {0}.", countEggs);
- continue;
- }else{
- countEggs -= buy_egg;
- counterSoldEggs += buy_egg;
- }
- }
- else if (comand == "Fill"){
- int fill_egs = int.Parse(Console.ReadLine());
- countEggs += fill_egs;
- }
- else{
- Console.WriteLine(" Incorrect command");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement