Guest User

Untitled

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