Advertisement
Guest User

08. Cookie Factory

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