Advertisement
veselka_a

6.BakingCompetition

Feb 27th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 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 _6.BakingCompetition
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int counterCookies = 0;
  15.             int counterCakes = 0;
  16.             int counterWaffles = 0;
  17.             int allBakerSold = 0;
  18.             double totalSumCharity = 0;
  19.  
  20.  
  21.             for (int i = 1; i <= n; i++)
  22.             {
  23.                 string bakerName = Console.ReadLine();
  24.                 string typeSweets = Console.ReadLine();
  25.  
  26.                 while (typeSweets!= "Stop baking!")
  27.                 {
  28.                     int quantitySweets = int.Parse(Console.ReadLine());
  29.  
  30.                     switch (typeSweets)
  31.                     {
  32.                         case "cookies": counterCookies += quantitySweets;totalSumCharity=totalSumCharity+quantitySweets*1.5 ; break;
  33.                         case "cakes": counterCakes += quantitySweets; totalSumCharity = totalSumCharity + quantitySweets * 7.8; break;
  34.                         case "waffles": counterWaffles += quantitySweets; totalSumCharity = totalSumCharity + quantitySweets * 2.3; break;
  35.  
  36.                     }
  37.                     typeSweets = Console.ReadLine();
  38.                 }
  39.                 Console.WriteLine($"{bakerName} baked {counterCookies} cookies, {counterCakes} cakes and {counterWaffles} waffles.");
  40.                 allBakerSold = allBakerSold+counterCakes + counterCookies + counterWaffles;
  41.  
  42.                 counterCakes = 0;
  43.                 counterCookies = 0;
  44.                 counterWaffles = 0;
  45.             }
  46.             Console.WriteLine($"All bakery sold: {allBakerSold}");
  47.             Console.WriteLine($"Total sum for charity: {totalSumCharity:f2} lv.");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement