VelizarAvramov

07. Cake Ingredients

Nov 5th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07._Cake_Ingredients
  4. {
  5.     class CakeIngredients
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //Write a baking program, which takes as an input ingredients and writes a message when the ingredient is in the system.
  10.             //For every given ingredient, you should write: “Adding ingredient {name of the ingredient}.”. When you receive the command
  11.             //“Bake!” from the console you should stop the program and write “Preparing cake with {number of given ingredients}
  12.             //ingredients.”.
  13.             string ingredient = Console.ReadLine();
  14.             int count = 0;
  15.  
  16.             while (ingredient != "Bake!")
  17.             {
  18.                 Console.WriteLine($"Adding ingredient {ingredient}.");
  19.                 count++;
  20.                 ingredient = Console.ReadLine();
  21.             }
  22.             Console.WriteLine($"Preparing cake with {count} ingredients.");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment