Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 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.  
  11. int cookiesCount = 0;
  12. int cakesCount = 0;
  13. int wafflesCount = 0;
  14.  
  15. int cookiesCounter = 0;
  16. int cakesCounter = 0;
  17. int wafflesCounter = 0;
  18.  
  19. for (int i = 1; i <= participants; i++)
  20. {
  21. string name = Console.ReadLine();
  22. string command = Console.ReadLine(); // "cookies", "cakes", "waffles"
  23.  
  24. while (command != "Stop baking!")
  25. {
  26. int sweetsCooked = int.Parse(Console.ReadLine());
  27.  
  28. if (command == "cookies")
  29. {
  30. cookiesCount += sweetsCooked;
  31. cookiesCounter += sweetsCooked;
  32. }
  33. else if (command == "cakes")
  34. {
  35. cakesCount += sweetsCooked;
  36. cakesCounter += sweetsCooked;
  37. }
  38. else if (command == "waffles")
  39. {
  40. wafflesCount += sweetsCooked;
  41. wafflesCounter += sweetsCooked;
  42. }
  43.  
  44. command = Console.ReadLine(); // "cookies", "cakes", "waffles"
  45. }
  46.  
  47. Console.WriteLine($"{name} baked {cookiesCount} cookies, {cakesCount} cakes and {wafflesCount} waffles.");
  48. cookiesCount = 0;
  49. cakesCount = 0;
  50. wafflesCount = 0;
  51. }
  52.  
  53. int totalSweets = cookiesCounter + cakesCounter + wafflesCounter;
  54. double sumForCharity = (cookiesCounter * 1.50) + (cakesCounter * 7.80) + (wafflesCounter * 2.30);
  55.  
  56. Console.WriteLine($"All bakery sold: {totalSweets}");
  57. Console.WriteLine($"Total sum for charity: {sumForCharity:F2} lv.");
  58.  
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement