desislava_topuzakova

06.BakeCompetition

May 1st, 2020
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.BakeCompetition
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int bakers = int.Parse(Console.ReadLine());
  10.             //за всеки сладкар -> 1 до последния (bakers)
  11.             int countAll = 0;
  12.  
  13.             int countAllCookies = 0;
  14.             int countAllCakes = 0;
  15.             int countAllWaffles = 0;
  16.  
  17.             for (int baker = 1; baker <= bakers; baker++)
  18.             {
  19.                 string name = Console.ReadLine(); // брой сладки, брой торти, брой гофрети
  20.                 int countCookiesPerBaker = 0;
  21.                 int countCakesPerBaker = 0;
  22.                 int countWafflesPerBaker = 0;
  23.  
  24.                 string type = Console.ReadLine(); //=>"Stop baking!" или тип сладкиш
  25.                 //STOP -> command == "Stop baking!"  -> command != "Stop baking!"
  26.  
  27.                 while (type != "Stop baking!")
  28.                 {
  29.                     //вид сладкиш -> "cookies", "cakes", "waffles"
  30.                     int count = int.Parse(Console.ReadLine());
  31.                     countAll += count;
  32.                     switch (type)
  33.                     {
  34.                         case "cookies":
  35.                             countCookiesPerBaker += count;
  36.                             countAllCookies += count;
  37.                             break;
  38.                         case "cakes":
  39.                             countCakesPerBaker += count;
  40.                             countAllCakes += count;
  41.                             break;
  42.                         case "waffles":
  43.                             countWafflesPerBaker += count;
  44.                             countAllWaffles += count;
  45.                             break;
  46.                     }
  47.  
  48.                     type = Console.ReadLine();
  49.                    
  50.                 }
  51.  
  52.                 Console.WriteLine($"{name} baked {countCookiesPerBaker} cookies, {countCakesPerBaker} cakes and {countWafflesPerBaker} waffles.");
  53.             }
  54.  
  55.             Console.WriteLine($"All bakery sold: {countAll}");
  56.             //СУМА = сладки(общ брой сладки * 1.5) + торти(общ брой торти * 7.80) + гофрети(общ брой гофрети * 2.30)
  57.             double totalSum = (countAllCookies * 1.50) + (countAllCakes * 7.80) + (countAllWaffles * 2.30);
  58.             Console.WriteLine($"Total sum for charity: {totalSum:F2} lv.");
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment