Guest User

08. Cookie factory

a guest
Jun 10th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 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 numberOfBatch = int.Parse(Console.ReadLine());
  10.             int counterOfBatch = 0;
  11.             int floorCounter = 0;
  12.             int sugarCounter = 0;
  13.             int eggCounter = 0;
  14.  
  15.             while (counterOfBatch < numberOfBatch)
  16.             {
  17.                 string name = Console.ReadLine();
  18.                 while (name != "Bake!")
  19.                 {
  20.                     if (name == "flour")
  21.                     {
  22.                         floorCounter++;
  23.                     }
  24.                     else if (name == "sugar")
  25.                     {
  26.                         sugarCounter++;
  27.                     }
  28.                     else if (name == "eggs")
  29.                     {
  30.                         eggCounter++;
  31.                     }
  32.  
  33.                     name = Console.ReadLine();
  34.  
  35.                 }
  36.  
  37.                 if (name == "Bake!")
  38.                 {
  39.  
  40.  
  41.                     if (eggCounter != 1 || sugarCounter != 1 || floorCounter != 1)
  42.                     {
  43.                         Console.WriteLine($"The batter should contain flour, eggs and sugar!");
  44.  
  45.                     }
  46.  
  47.                     else if (eggCounter == 1 && sugarCounter == 1 && floorCounter == 1)
  48.                     {
  49.                         counterOfBatch++;
  50.                         Console.WriteLine($"Baking batch number {counterOfBatch}...");
  51.                         floorCounter = 0;
  52.                         sugarCounter = 0;
  53.                         eggCounter = 0;
  54.                     }
  55.  
  56.  
  57.                 }
  58.  
  59.  
  60.  
  61.  
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment