desito07

Flowers

Apr 18th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. function flowers(input) {
  2. let countH = +input.shift();
  3. let countR = +input.shift();
  4. let countL = +input.shift();
  5. let season = input.shift();
  6. let day = input.shift();
  7.  
  8. let price = 1;
  9. let count = countH + countL + countR;
  10.  
  11. if (season === "Spring" || season === "Summer") {
  12. price = countH * 2 + countR * 4.1 + countL * 2.5;
  13. if (day === "Y") {
  14. price += price * 0.15;
  15. if (countL > 7 && season !== "Summer") {
  16. price -= price * 0.05;
  17. }
  18. if (count > 20) {
  19. price -= price * 0.2;
  20. }
  21. } else if (day === "N") {
  22. price = countH * 2 + countR * 4.1 + countL * 2.5;
  23. }
  24. if (count > 20) {
  25. price -= price * 0.2;
  26. }
  27. } else if (season === "Autumn" || season === "Winter") {
  28. price = countH * 3.75 + countR * 4.5 + countL * 4.15;
  29. if (day === "Y") {
  30. price += price * 0.15;
  31. if (count > 20) {
  32. price -= price * 0.2;
  33. }
  34. } else if (day === "N") {
  35. price = countH * 3.75 + countR * 4.5 + countL * 4.15;
  36. }
  37. if (countR >= 10 && season != "Autumn") {
  38. price -= price * 0.1;
  39. }
  40. if (count > 20) {
  41. price -= price * 0.2;
  42. }
  43. }
  44. console.log((price + 2).toFixed(2));
  45. }
Advertisement
Add Comment
Please, Sign In to add comment