spasnikolov131

Untitled

Jul 19th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Easter_Decoration
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double basket = 1.50;
  10. double wreath = 3.80;
  11. double chocolateBunny = 7;
  12. int purchasedItems = 0;
  13. double price = 0;
  14. string line = "";
  15. double average = 0;
  16.  
  17. int countClientsInTheShop = int.Parse(Console.ReadLine());
  18.  
  19. for (int i = 0; i < countClientsInTheShop; i++)
  20. {
  21. line = Console.ReadLine();
  22. while (line != "Finish")
  23. {
  24. switch (line)
  25. {
  26. case "basket":
  27. price += basket;
  28. purchasedItems++;
  29. break;
  30. case "wreath":
  31. price += wreath;
  32. purchasedItems++;
  33. break;
  34. case "chocolate bunny":
  35. price += chocolateBunny;
  36. purchasedItems++;
  37. break;
  38. case "Finish":
  39. if (purchasedItems % 2 == 0)
  40. {
  41. price *= 0.80;
  42. average += price;
  43. Console.WriteLine($"You purchased {purchasedItems} items for {price:f2} leva.");
  44. }
  45. break;
  46. }
  47.  
  48. line = Console.ReadLine();
  49. }
  50.  
  51. }
  52. average /= countClientsInTheShop;
  53. Console.WriteLine($"Average bill per client is: {average:f2} leva.");
  54. }
  55. }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment