Advertisement
desislava_topuzakova

03. New House

May 15th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03._New_House
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string flowerType = Console.ReadLine(); // "Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus"
  10. int count = int.Parse(Console.ReadLine()); //брой цветята
  11. int budget = int.Parse(Console.ReadLine()); //предвиден бюджет
  12.  
  13. //1. крайна цена = бр. цветята (count) * цена за 1 цвете (priceFlower)
  14. double priceFlower = 0; //цена за 1 цвете, зависи от вид на цветето
  15. //flowerType -> серия от проверки за точни стойности
  16. //"Roses" -> 5
  17. //"Dahlias" -> 3.80
  18. //"Tulips" -> 2.80
  19. //"Narcissus" -> 3
  20. //"Gladiolus" -> 2.50
  21.  
  22. switch (flowerType)
  23. {
  24. case "Roses":
  25. priceFlower = 5;
  26. break;
  27. case "Dahlias":
  28. priceFlower = 3.80;
  29. break;
  30. case "Tulips":
  31. priceFlower = 2.80;
  32. break;
  33. case "Narcissus":
  34. priceFlower = 3;
  35. break;
  36. case "Gladiolus":
  37. priceFlower = 2.50;
  38. break;
  39. }
  40.  
  41. double totalPrice = count * priceFlower; //крайна цена
  42.  
  43. //2. отстъпки
  44. //повече от 80 Рози -> 10%
  45. if (count > 80 && flowerType == "Roses")
  46. {
  47. totalPrice = totalPrice - 0.10 * totalPrice;
  48. //totalPrice = 0.9 * totalPrice;
  49. //totalPrice *= 0.9;
  50. }
  51. //повече от 90 Далии - 15 %
  52. else if (count > 90 && flowerType == "Dahlias")
  53. {
  54. totalPrice = totalPrice - 0.15 * totalPrice;
  55. //totalPrice = 0.85 * totalPrice;
  56. //totalPrice *= 0.85;
  57. }
  58. //повече от 80 Лалета - 15%
  59. else if (count > 80 && flowerType == "Tulips")
  60. {
  61. totalPrice = totalPrice - 0.15 * totalPrice;
  62. //totalPrice = 0.85 * totalPrice;
  63. //totalPrice *= 0.85;
  64. }
  65. //по-малко от 120 Нарциса +15%
  66. else if (count < 120 && flowerType == "Narcissus")
  67. {
  68. totalPrice = totalPrice + 0.15 * totalPrice;
  69. //totalPrice = 1.15 * totalPrice;
  70. //totalPrice *= 1.15;
  71. }
  72. //по-малко от 80 Гладиоли + 20%
  73. else if (count < 80 && flowerType == "Gladiolus")
  74. {
  75. totalPrice = totalPrice + 0.20 * totalPrice;
  76. //totalPrice = 1.2 * totalPrice;
  77. //totalPrice *= 1.2;
  78. }
  79.  
  80.  
  81. //3. проверка за бюджетът
  82. //крайна сума: totalPrice
  83. //предвиденият бюджет: budget
  84.  
  85. //достатъчен
  86. if (budget >= totalPrice)
  87. {
  88. double leftSum = budget - totalPrice; //останала сума
  89. Console.WriteLine($"Hey, you have a great garden with {count} {flowerType} and {leftSum:F2} leva left.");
  90. }
  91. else
  92. {
  93. //budget < totalPrice -> не е достатъчен
  94. double needSum = totalPrice - budget; //нужна сума
  95. Console.WriteLine($"Not enough money, you need {needSum:F2} leva more.");
  96.  
  97. }
  98.  
  99.  
  100.  
  101. }
  102. }
  103. }
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement