Advertisement
mivanchova

6. Baking Competition 100/100

Feb 29th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Baking_Competition
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int participants = int.Parse(Console.ReadLine());
  10. int numberBakerys = 0;
  11. double totalSum = 0;
  12. for (int i = 1; i <= participants; i++)
  13. {
  14. int cookies = 0;
  15. int cakes = 0;
  16. int waffles = 0;
  17. string name = Console.ReadLine();
  18. string bakery = Console.ReadLine();
  19. while (bakery != "Stop baking!")
  20. {
  21. int bakeryNumb = int.Parse(Console.ReadLine());
  22. if (bakery == "cookies")
  23. {
  24. cookies += bakeryNumb;
  25. }
  26. else if (bakery == "cakes")
  27. {
  28. cakes += bakeryNumb;
  29. }
  30. else if (bakery == "waffles")
  31. {
  32. waffles += bakeryNumb;
  33. }
  34. bakery = Console.ReadLine();
  35. }
  36. if (bakery == "Stop baking!")
  37. {
  38. numberBakerys += cookies + cakes + waffles;
  39. totalSum += cookies * 1.50 + cakes * 7.80 + waffles * 2.30;
  40. Console.WriteLine($"{name} baked {cookies} cookies, {cakes} cakes and {waffles} waffles.");
  41. }
  42. }
  43.  
  44. Console.WriteLine($"All bakery sold: {numberBakerys}");
  45. Console.WriteLine($"Total sum for charity: {totalSum:f2} lv.");
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement