Advertisement
bokoto83

Baking Competition

Jul 28th, 2019
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 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 Baking_Competition
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberPeople = int.Parse(Console.ReadLine());
  14.                 int backery = 0;
  15.                 double total = 0;
  16.             for (int i = 0; i < numberPeople; i++)
  17.             {
  18.                 int cookies = 0;
  19.                 int cakes = 0;
  20.                 int waffles = 0;
  21.                 string name = Console.ReadLine();
  22.                 string typeSweet = "";
  23.                 int numberBaked = 0;
  24.                
  25.                 while (typeSweet != "Stop baking!")
  26.                 {
  27.                     typeSweet = Console.ReadLine();
  28.                     if (typeSweet == "Stop baking!")
  29.                     {
  30.                         break;
  31.                     }
  32.                     numberBaked = int.Parse(Console.ReadLine());
  33.                     if (typeSweet == "cookies")
  34.                     {
  35.                         cookies = numberBaked;
  36.                     }
  37.                     else if (typeSweet == "cakes")
  38.                     {
  39.                         cakes = numberBaked;
  40.                     }
  41.                     else if (typeSweet == "waffles")
  42.                     {
  43.                         waffles = numberBaked;
  44.                     }
  45.                 }
  46.                  total += cookies * 1.50 + cakes * 7.80 + waffles * 2.30;
  47.                 Console.WriteLine($"{name} baked {cookies} cookies, {cakes} cakes and {waffles} waffles.");
  48.                  backery += waffles + cakes + cookies;
  49.             }
  50.             Console.WriteLine($"All bakery sold: {backery}");
  51.             Console.WriteLine($"Total sum for charity: {total:f2} lv.");
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement