Advertisement
desislava_topuzakova

05. Small Shop

Oct 14th, 2023
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. string product = Console.ReadLine(); // "coffee", "water", "beer", "sweets", "peanuts"
  2. string town = Console.ReadLine(); //"Sofia", "Plovdiv", "Varna"
  3. double quantity = double.Parse(Console.ReadLine());
  4.  
  5. //КРАЙНА ЦЕНА = КОЛИЧЕСТВО(quantity) * ЦЕНА ЗА 1 ПРОДУКТ (price)
  6.  
  7. double price = 0; //цена на продукта
  8.  
  9. switch (town)
  10. {
  11. case "Sofia":
  12. //проверка за продукта в София
  13. if (product == "coffee")
  14. {
  15. price = 0.50;
  16. }
  17. else if (product == "water")
  18. {
  19. price = 0.80;
  20. }
  21. else if (product == "beer")
  22. {
  23. price = 1.20;
  24. }
  25. else if (product == "sweets")
  26. {
  27. price = 1.45;
  28. }
  29. else if (product == "peanuts")
  30. {
  31. price = 1.60;
  32. }
  33. break;
  34. case "Plovdiv":
  35. //проверка за продукта в Пловдив
  36. if (product == "coffee")
  37. {
  38. price = 0.40;
  39. }
  40. else if (product == "water")
  41. {
  42. price = 0.70;
  43. }
  44. else if (product == "beer")
  45. {
  46. price = 1.15;
  47. }
  48. else if (product == "sweets")
  49. {
  50. price = 1.30;
  51. }
  52. else if (product == "peanuts")
  53. {
  54. price = 1.50;
  55. }
  56. break;
  57. case "Varna":
  58. //проверка за продукта във Варна
  59. if (product == "coffee")
  60. {
  61. price = 0.45;
  62. }
  63. else if (product == "water")
  64. {
  65. price = 0.70;
  66. }
  67. else if (product == "beer")
  68. {
  69. price = 1.10;
  70. }
  71. else if (product == "sweets")
  72. {
  73. price = 1.35;
  74. }
  75. else if (product == "peanuts")
  76. {
  77. price = 1.55;
  78. }
  79. break;
  80. }
  81.  
  82. //единична цена на продукта
  83. double finalPrice = quantity * price;
  84. Console.WriteLine(finalPrice);
  85.  
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement