Advertisement
knikolov98

Untitled

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