Advertisement
ralichka

Nested.Loop.Lab - 08.Cookie.Factory

Jul 13th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace demo
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             int count = int.Parse(Console.ReadLine());
  11.  
  12.             bool eggs = false;
  13.             bool flour = false;
  14.             bool sugar = false;
  15.  
  16.             for (int i = 1; i <= count; i++)
  17.             {
  18.                 string command = Console.ReadLine();
  19.  
  20.                 while (command != "Bake")
  21.                 {
  22.                     if (command == "sugar")
  23.                     {
  24.                         sugar = true;
  25.                     }
  26.                     else if (command == "eggs")
  27.                     {
  28.                         eggs = true;
  29.                     }
  30.                     else if (command == "flour")
  31.                     {
  32.                         flour = true;
  33.                     }
  34.  
  35.                     command = Console.ReadLine();
  36.                 }
  37.  
  38.                 if (command == "Bake" && eggs && sugar && flour)
  39.                 {
  40.                     Console.WriteLine($"Baking batch number {i} …");
  41.                     eggs = false;
  42.                     flour = false;
  43.                     sugar = false;
  44.                 }
  45.                 else
  46.                 {
  47.                     Console.WriteLine("The batter should contain flour, eggs and sugar!");
  48.                     i--;
  49.                    
  50.                 }
  51.  
  52.             }
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement