Advertisement
kirililchev3

Cake Ingredients - While loop

May 20th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P07CakeIngredients
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string ingredient = Console.ReadLine();
  10.             int ingredientsCount = 0;
  11.  
  12.             while (ingredient != "Bake!")
  13.             {
  14.                 ingredientsCount++;
  15.                 Console.WriteLine($"Adding ingredient {ingredient}.");
  16.                 ingredient = Console.ReadLine();
  17.             }
  18.  
  19.             Console.WriteLine($"Preparing cake with {ingredientsCount} ingredients.");
  20.  
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement