Advertisement
spasnikolov131

Untitled

Jul 19th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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.  
  15. double average = 0;
  16.  
  17. int countClientsInTheShop = int.Parse(Console.ReadLine());
  18.  
  19. for (int i = 1; i <= countClientsInTheShop; i++)
  20. {
  21. string line = Console.ReadLine();
  22.  
  23. while (line != "Finish")
  24. {
  25. switch (line)
  26. {
  27. case "basket":
  28. price += basket;
  29. purchasedItems++;
  30. break;
  31. case "wreath":
  32. price += wreath;
  33. purchasedItems++;
  34. break;
  35. case "chocolate bunny":
  36. price += chocolateBunny;
  37. purchasedItems++;
  38. break;
  39.  
  40. }
  41.  
  42. line = Console.ReadLine();
  43. }
  44.  
  45. if (purchasedItems % 2 == 0)
  46. {
  47. price *= 0.80;
  48. average += price;
  49. Console.WriteLine($"You purchased {purchasedItems} items for {price:f2} leva.");
  50. }
  51.  
  52.  
  53. }
  54. average /= countClientsInTheShop;
  55. Console.WriteLine($"Average bill per client is: {average:f2} leva.");
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement