aggressiveviking

Untitled

Feb 21st, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.BakingCompetition
  4. {
  5.     class BakingCompetition
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int participantCount = int.Parse(Console.ReadLine());
  10.  
  11.             double totalCount = 0;
  12.             double totalSum = 0.0;
  13.  
  14.             double priceCookies = 1.50;
  15.             double priceCakes = 7.80;
  16.             double priceWaffles = 2.30;
  17.  
  18.             for (int i = 0; i < participantCount; i++)
  19.             {
  20.  
  21.                 double cookiesCount = 0;
  22.                 double cakesCount = 0;
  23.                 double wafflesCount = 0;
  24.  
  25.                 double cookiesSum = 0;
  26.                 double cakesSum = 0;
  27.                 double wafflesSum = 0;
  28.  
  29.  
  30.                 string participantName = Console.ReadLine();
  31.                 string sweetsType = Console.ReadLine();
  32.  
  33.                 while (sweetsType != "Stop baking!")
  34.                 {
  35.                     int sweetieCount = int.Parse(Console.ReadLine());
  36.  
  37.                     switch (sweetsType)
  38.                     {
  39.                         case "cookies":
  40.                             cookiesCount = sweetieCount;
  41.                             totalCount += cookiesCount;
  42.                             cookiesSum = cookiesCount * priceCookies;
  43.                             totalSum += cookiesSum;
  44.                             break;
  45.  
  46.                         case "cakes":
  47.                             cakesCount = sweetieCount;
  48.                             totalCount += cakesCount;
  49.                             cakesSum = cakesCount * priceCakes;
  50.                             totalSum += cakesSum;
  51.                             break;
  52.  
  53.                         case "waffles":
  54.                             wafflesCount = sweetieCount;
  55.                             totalCount += wafflesCount;
  56.                             wafflesSum = wafflesCount * priceWaffles;
  57.                             totalSum += wafflesSum;
  58.                             break;
  59.                     }
  60.  
  61.                     sweetsType = Console.ReadLine();
  62.                 }
  63.  
  64.                 Console.WriteLine($"{participantName}s baked {cookiesCount:f0} cookies, {cakesCount:f0} cakes and {wafflesCount:f0} waffles.");
  65.             }
  66.  
  67.             Console.WriteLine($"All bakery sold: {totalCount}");
  68.             Console.WriteLine($"Total sum for charity: {totalSum:f2} lv.");
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment