bokoto83

Cookie factory

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