Advertisement
ErolKZ

Untitled

Jul 1st, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1.  
  2. function solve(input) {
  3.  
  4. let buyedHrizantem = Number(input[0]);
  5.  
  6. let buyedRoses = Number(input[1]);
  7.  
  8. let buyedTulips = Number(input[2]);
  9.  
  10. let season = input[3];
  11.  
  12. let holidayYesNo = input[4];
  13.  
  14. let totalFLowers = 0;
  15.  
  16. let countFlowers = buyedHrizantem + buyedRoses + buyedTulips;
  17.  
  18.  
  19.  
  20. if (holidayYesNo === 'Y' && (season === 'Spring' || season === 'Summer')) {
  21.  
  22. buyedHrizantem = buyedHrizantem * 2.00;
  23.  
  24. buyedRoses = buyedRoses * 4.10;
  25.  
  26. buyedTulips = buyedTulips * 2.50;
  27.  
  28. totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
  29. totalFLowers = totalFLowers + (totalFLowers * (15 / 100));
  30.  
  31.  
  32. if (season === 'Spring' && buyedTulips > 7) {
  33.  
  34. totalFLowers = totalFLowers - (totalFLowers * (5 / 100));
  35.  
  36. }
  37.  
  38.  
  39.  
  40.  
  41. } else if (holidayYesNo === 'N' && (season === 'Spring' || season === 'Summer')) {
  42.  
  43. buyedHrizantem = buyedHrizantem * 2.00;
  44. buyedRoses = buyedRoses * 4.10;
  45. buyedTulips = buyedTulips * 2.50;
  46.  
  47. totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
  48.  
  49.  
  50. if (season === 'Spring' && buyedTulips > 7) {
  51.  
  52. totalFLowers = totalFLowers - (totalFLowers * (5 / 100));
  53.  
  54. }
  55.  
  56.  
  57. } else if (holidayYesNo === 'Y' && (season === 'Autumn' || season === 'Winter')) {
  58.  
  59.  
  60. buyedHrizantem = buyedHrizantem * 3.75;
  61.  
  62. buyedRoses = buyedRoses * 4.50;
  63.  
  64. buyedTulips = buyedTulips * 4.15;
  65.  
  66.  
  67. totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
  68. totalFLowers = totalFLowers + (totalFLowers * (15 / 100));
  69.  
  70.  
  71.  
  72.  
  73.  
  74. if (season === 'Winter' && buyedRoses >= 10) {
  75.  
  76. totalFLowers = totalFLowers - (totalFLowers * (10 / 100));
  77.  
  78. }
  79.  
  80.  
  81. } else if (holidayYesNo === 'N' && (season === 'Autumn' || season === 'Winter')) {
  82.  
  83.  
  84. buyedHrizantem = buyedHrizantem * 3.75;
  85.  
  86. buyedRoses = buyedRoses * 4.50;
  87.  
  88. buyedTulips = buyedTulips * 4.15;
  89.  
  90.  
  91. totalFLowers = buyedHrizantem + buyedRoses + buyedTulips;
  92.  
  93.  
  94. if (season === 'Winter' && buyedRoses >= 10) {
  95.  
  96. totalFLowers = totalFLowers - (totalFLowers * (10 / 100));
  97.  
  98. }
  99.  
  100.  
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. if (countFlowers > 20) {
  109.  
  110. totalFLowers = totalFLowers - (totalFLowers * (20 / 100));
  111.  
  112. }
  113.  
  114.  
  115. totalFLowers = totalFLowers + 2;
  116.  
  117.  
  118. console.log(totalFLowers.toFixed(2));
  119.  
  120.  
  121. }
  122.  
  123.  
  124. solve([
  125.  
  126.  
  127. '2',
  128.  
  129. '4',
  130.  
  131. '8',
  132.  
  133. 'Spring',
  134.  
  135. 'N'
  136.  
  137.  
  138. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement