Advertisement
madeofglass

Untitled

Feb 21st, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 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.  
  10.             double contestants = double.Parse(Console.ReadLine());
  11.  
  12.             double price = 0.0;
  13.             double overallPrice = 0.0;
  14.  
  15.             double counter = 0;
  16.  
  17.             for (int i = 1; i <= contestants; i++)
  18.             {
  19.                 string name = Console.ReadLine();
  20.  
  21.                 double counterC = 0;
  22.                 double counterCa = 0;
  23.                 double counterW = 0;
  24.  
  25.                 while (true)
  26.                 {
  27.                     string pastryName = Console.ReadLine();
  28.  
  29.                     if (pastryName == "Stop baking!")
  30.                     {
  31.                         Console.WriteLine($"{name} baked {counterC} cookies, {counterCa} cakes and {counterW} waffles.");
  32.                         break;
  33.                     }
  34.  
  35.                     double numberBaked = double.Parse(Console.ReadLine());
  36.                     counter += numberBaked;
  37.  
  38.                     if (pastryName == "cookies")
  39.                     {
  40.                         price = numberBaked * 1.50;
  41.                         counterC += numberBaked;
  42.                     }
  43.                     else if (pastryName == "cakes")
  44.                     {
  45.                         price = numberBaked * 7.80;
  46.                         counterCa += numberBaked;
  47.  
  48.                     }
  49.                     else if (pastryName == "waffles")
  50.                     {
  51.                         price = numberBaked * 2.30;
  52.                         counterW += numberBaked;
  53.                     }
  54.                     overallPrice += price;
  55.                 }
  56.             }
  57.  
  58.             Console.WriteLine($"All bakery sold: {counter}");
  59.             Console.WriteLine($"Total sum for charity: {overallPrice:f2} lv.");
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement