Advertisement
nnikolov

Untitled

Mar 4th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08._Fruit_Shop
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. // banana apple orange grapefruit kiwi pineapple grapes
  10. // 2.50 1.20 0.85 1.45 2.70 5.50 3.85
  11.  
  12. //banana apple orange grapefruit kiwi pineapple grapes
  13. // 2.70 1.25 0.90 1.60 3.00 5.60 4.20
  14.  
  15.  
  16. string fruit = Console.ReadLine();
  17. string day = Console.ReadLine();
  18. double quantity = double.Parse(Console.ReadLine());
  19.  
  20. double price = 0;
  21.  
  22.  
  23.  
  24. if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday")
  25. {
  26. switch (fruit)
  27. {
  28. case ("banana"):
  29. price = 2.50;
  30. break;
  31. case ("apple"):
  32. price = 1.20;
  33. break;
  34. case ("orange"):
  35. price = 0.85;
  36. break;
  37. case ("grapefruit"):
  38. price = 1.45;
  39. break;
  40. case ("kiwi"):
  41. price = 2.70;
  42. break;
  43. case ("pineapple"):
  44. price = 5.50;
  45. break;
  46. case ("grapes"):
  47. price = 3.85;
  48. break;
  49. default:
  50. Console.WriteLine("error");
  51. break;
  52.  
  53. }
  54. double totalPrice = price * quantity;
  55. Console.WriteLine($"{totalPrice:F2}");
  56. }
  57. else if (day == "Saturday" || day == "Sunday")
  58. {
  59. switch (fruit)
  60. {
  61. case ("banana"):
  62. price = 2.70;
  63. break;
  64. case ("apple"):
  65. price = 1.25;
  66. break;
  67. case ("orange"):
  68. price = 0.90;
  69. break;
  70. case ("grapefruit"):
  71. price = 1.60;
  72. break;
  73. case ("kiwi"):
  74. price = 3.00;
  75. break;
  76. case ("pineapple"):
  77. price = 5.60;
  78. break;
  79. case ("grapes"):
  80. price = 4.20;
  81. break;
  82. default:
  83. Console.WriteLine("error");
  84. break;
  85.  
  86. }
  87. double totalPrice = price * quantity;
  88. Console.WriteLine($"{totalPrice:F2}");
  89. }
  90. else
  91. {
  92. Console.WriteLine("error");
  93. }
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement