Advertisement
Valantina

BakingCompetition/Ex/27.07.2019

Jul 29th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P06_BakingCompetition
  4. {
  5.     class P06_BakingCompetition
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int bakers = int.Parse(Console.ReadLine());
  10.  
  11.             double totalSum = 0.0;
  12.             int totalSweetsCnt = 0;
  13.  
  14.             for (int i = 0; i < bakers; i++)
  15.             {
  16.                 string bakerName = Console.ReadLine();
  17.  
  18.                 int cookiesCnt = 0;
  19.                 int cakesCnt = 0;
  20.                 int wafflesCnt = 0;
  21.  
  22.                 string sweetName = Console.ReadLine();
  23.                 while ("Stop baking!" != sweetName)
  24.                 {
  25.                     int sweetsCnt = int.Parse(Console.ReadLine());
  26.                     switch (sweetName)
  27.                     {
  28.                         case "cookies":
  29.                             cookiesCnt += sweetsCnt;
  30.                             break;
  31.                         case "cakes":
  32.                             cakesCnt += sweetsCnt;
  33.                             break;
  34.                         case "waffles":
  35.                             wafflesCnt += sweetsCnt;
  36.                             break;
  37.                     }
  38.                     sweetName = Console.ReadLine();
  39.                 }
  40.                 totalSum += ((cookiesCnt * 1.5) + (cakesCnt * 7.8) + (wafflesCnt * 2.3));
  41.                 totalSweetsCnt += (cookiesCnt + cakesCnt + wafflesCnt);
  42.                 Console.WriteLine($"{bakerName} baked {cookiesCnt} cookies, {cakesCnt} cakes and {wafflesCnt} waffles.");
  43.             }
  44.             Console.WriteLine($"All bakery sold: {totalSweetsCnt}");
  45.             Console.WriteLine($"Total sum for charity: {totalSum:F2} lv.");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement