SaintMalthus

Untitled

Jan 20th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1.  
  2. using System;
  3.  
  4. namespace P11FruitShop
  5. {
  6. internal class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. // 1. Read the input from the user
  11. // - Fruit 'text' (string)
  12. // - Day from the week 'text' (string)
  13. // - Quantity 'real number' (double)
  14. // - Make veriable that contain total sum 'real number' (double)
  15.  
  16. string fruit = Console.ReadLine();
  17. string day = Console.ReadLine();
  18. double qty = double.Parse(Console.ReadLine());
  19. double totalSum = 0;
  20.  
  21. // - Fruit prices in working day
  22. //плод banana apple orange grapefruit kiwi pineapple grapes
  23. //цена 2.50 1.20 0.85 1.45 2.70 5.50 3.85
  24.  
  25. // - Fruit prices trough weekend
  26. //плод banana apple orange grapefruit kiwi pineapple grapes
  27. //цена 2.70 1.25 0.90 1.60 3.00 5.60 4.20
  28.  
  29. switch (day)
  30. {
  31. case "Monday":
  32. case "Tuesday":
  33. case "Wednesday":
  34. case "Thursday":
  35. case "Friday":
  36. switch (fruit)
  37. {
  38. case "banana":
  39. totalSum = qty * 2.50;
  40. break;
  41. case "apple":
  42. totalSum = qty * 1.20;
  43. break;
  44. case "orange":
  45. totalSum = qty * 0.85;
  46. break;
  47. case "grapefruit":
  48. totalSum = qty * 1.45;
  49. break;
  50. case "kiwi":
  51. totalSum = qty * 2.70;
  52. break;
  53. case "pineapple":
  54. totalSum = qty * 5.50;
  55. break;
  56. case "grapes":
  57. totalSum = qty * 3.85;
  58. break;
  59. default:
  60. Console.WriteLine("error");
  61. break;
  62. }
  63. break;
  64.  
  65. case "Saturday":
  66. case "Sunday":
  67. switch (fruit)
  68. {
  69. case "banana":
  70. totalSum = qty * 2.70;
  71. break;
  72. case "apple":
  73. totalSum = qty * 1.25;
  74. break;
  75. case "orange":
  76. totalSum = qty * 0.90;
  77. break;
  78. case "grapefruit":
  79. totalSum = qty * 1.60;
  80. break;
  81. case "kiwi":
  82. totalSum = qty * 3.00;
  83. break;
  84. case "pineapple":
  85. totalSum = qty * 5.60;
  86. break;
  87. case "grapes":
  88. totalSum = qty * 4.20;
  89. break;
  90. default:
  91. Console.WriteLine("error");
  92. break;
  93.  
  94. }
  95. break;
  96.  
  97. default:
  98. Console.WriteLine("error");
  99. break;
  100.  
  101.  
  102. }
  103.  
  104. Console.WriteLine($"{totalSum:f2}");
  105.  
  106. }
  107. }
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment