zh_stoqnov

Fruit Market

Oct 29th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Fruit_Market
  4. {
  5. class FruitMarket
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string dayOfWeek = Console.ReadLine();
  10. double quantity1 = double.Parse(Console.ReadLine());
  11. string product1 = Console.ReadLine();
  12. double quantity2 = double.Parse(Console.ReadLine());
  13. string product2 = Console.ReadLine();
  14. double quantity3 = double.Parse(Console.ReadLine());
  15. string product3 = Console.ReadLine();
  16.  
  17. double banana = 1.8;
  18. double cucumber = 2.75;
  19. double tomato = 3.2;
  20. double orange = 1.6;
  21. double apple = 0.86;
  22. double totalPrice = 0;
  23. double firstProduct = 0;
  24. double secondProduct = 0;
  25. double thirdProduct = 0;
  26.  
  27. switch (product1)
  28. {
  29. case "banana": firstProduct = quantity1 * banana; break;
  30. case "cucumber": firstProduct = quantity1 * cucumber; break;
  31. case "tomato": firstProduct = quantity1 * tomato; break;
  32. case "orange": firstProduct = quantity1 * orange; break;
  33. case "apple": firstProduct = quantity1 * apple; break;
  34. }
  35. switch (product2)
  36. {
  37. case "banana": secondProduct = quantity2 * banana; break;
  38. case "cucumber": secondProduct = quantity2 * cucumber; break;
  39. case "tomato": secondProduct = quantity2 * tomato; break;
  40. case "orange": secondProduct = quantity2 * orange; break;
  41. case "apple": secondProduct = quantity2 * apple; break;
  42. }
  43. switch (product3)
  44. {
  45. case "banana": thirdProduct = quantity3 * banana; break;
  46. case "cucumber": thirdProduct = quantity3 * cucumber; break;
  47. case "tomato": thirdProduct = quantity3 * tomato; break;
  48. case "orange": thirdProduct = quantity3 * orange; break;
  49. case "apple": thirdProduct = quantity3 * apple; break;
  50. }
  51. totalPrice = firstProduct + secondProduct + thirdProduct;
  52. if(dayOfWeek == "Friday")
  53. {
  54. totalPrice = totalPrice - totalPrice * 0.1;
  55. Console.WriteLine("{0:0.00}", totalPrice);
  56. }
  57. else if(dayOfWeek == "Sunday")
  58. {
  59. totalPrice = totalPrice - totalPrice * 0.05;
  60. Console.WriteLine("{0:0.00}", totalPrice);
  61. }
  62. else if(dayOfWeek == "Tuesday")
  63. {
  64. switch (product3)
  65. {
  66. case "banana": thirdProduct = quantity3 * banana - quantity3 * banana * 0.2;break;
  67. case "orange": thirdProduct = quantity3 * orange - quantity3 * orange * 0.2; break;
  68. case "apple": thirdProduct = quantity3 * apple - quantity3 * apple * 0.2; break;
  69. case "tomato": thirdProduct = quantity3 * tomato; break;
  70. case "cucumber": thirdProduct = quantity3 * cucumber; break;
  71. }
  72. switch (product2)
  73. {
  74. case "banana": secondProduct = quantity2 * banana - quantity2 * banana * 0.2; break;
  75. case "orange": secondProduct = quantity2 * orange - quantity2 * orange * 0.2; break;
  76. case "apple": secondProduct = quantity2 * apple - quantity2 * apple * 0.2; break;
  77. case "tomato": secondProduct = quantity2 * tomato; break;
  78. case "cucumber": secondProduct = quantity2 * cucumber; break;
  79. }
  80. switch (product1)
  81. {
  82. case "banana": firstProduct = quantity1 * banana - quantity1 * banana * 0.2; break;
  83. case "orange": firstProduct = quantity1 * orange - quantity1 * orange * 0.2; break;
  84. case "apple": firstProduct = quantity1 * apple - quantity1 * apple * 0.2; break;
  85. case "tomato": firstProduct = quantity1 * tomato; break;
  86. case "cucumber": firstProduct = quantity1 * cucumber; break;
  87. }
  88. totalPrice = firstProduct + secondProduct + thirdProduct;
  89. Console.WriteLine("{0:0.00}", totalPrice);
  90. }
  91.  
  92. else if (dayOfWeek == "Wednesday")
  93. {
  94. switch (product1)
  95. {
  96. case "banana": firstProduct = quantity1 * banana; break;
  97. case "cucumber": firstProduct = quantity1 * cucumber - quantity1 * cucumber * 0.1; break;
  98. case "tomato": firstProduct = quantity1 * tomato - quantity1 * tomato * 0.1; break;
  99. case "orange": firstProduct = quantity1 * orange; break;
  100. case "apple": firstProduct = quantity1 * apple; break;
  101. }
  102. switch (product2)
  103. {
  104. case "banana": secondProduct = quantity2 * banana; break;
  105. case "cucumber": secondProduct = quantity2 * cucumber - quantity2 * cucumber * 0.1; break;
  106. case "tomato": secondProduct = quantity2 * tomato - quantity2 * tomato * 0.1; break;
  107. case "orange": secondProduct = quantity2 * orange; break;
  108. case "apple": secondProduct = quantity2 * apple; break;
  109. }
  110. switch (product3)
  111. {
  112. case "banana": thirdProduct = quantity3 * banana; break;
  113. case "cucumber": thirdProduct = quantity3 * cucumber - quantity3 * cucumber * 0.1; break;
  114. case "tomato": thirdProduct = quantity3 * tomato - quantity3 * tomato * 0.1; break;
  115. case "orange": thirdProduct = quantity3 * orange; break;
  116. case "apple": thirdProduct = quantity3 * apple; break;
  117. }
  118. totalPrice = firstProduct + secondProduct + thirdProduct;
  119. Console.WriteLine("{0:0.00}", totalPrice);
  120. }
  121.  
  122. else if (dayOfWeek == "Thursday")
  123. {
  124. switch (product1)
  125. {
  126. case "banana": firstProduct = quantity1 * banana - quantity1 * banana * 0.3; break;
  127. case "cucumber": firstProduct = quantity1 * cucumber; break;
  128. case "tomato": firstProduct = quantity1 * tomato; break;
  129. case "orange": firstProduct = quantity1 * orange; break;
  130. case "apple": firstProduct = quantity1 * apple; break;
  131. }
  132. switch (product2)
  133. {
  134. case "banana": secondProduct = quantity2 * banana - quantity2 * banana * 0.3; break;
  135. case "cucumber": secondProduct = quantity2 * cucumber; break;
  136. case "tomato": secondProduct = quantity2 * tomato; break;
  137. case "orange": secondProduct = quantity2 * orange; break;
  138. case "apple": secondProduct = quantity2 * apple; break;
  139. }
  140. switch (product3)
  141. {
  142. case "banana": thirdProduct = quantity3 * banana - quantity3 * banana * 0.3; break;
  143. case "cucumber": thirdProduct = quantity3 * cucumber; break;
  144. case "tomato": thirdProduct = quantity3 * tomato; break;
  145. case "orange": thirdProduct = quantity3 * orange; break;
  146. case "apple": thirdProduct = quantity3 * apple; break;
  147. }
  148. totalPrice = firstProduct + secondProduct + thirdProduct;
  149. Console.WriteLine("{0:0.00}", totalPrice);
  150. }
  151.  
  152. else
  153. {
  154. Console.WriteLine("{0:0.00}", totalPrice);
  155. }
  156.  
  157. }
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment