Advertisement
Guest User

Untitled

a guest
Mar 15th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. function flowers (input) {
  2. let boughtHrizantems = Number(input[0]);
  3. let boughtRoses = Number(input[1]);
  4. let boughtTulips = Number(input[2]);
  5. let season = input[3];
  6. let ifHoliday = input[4];
  7. let totalPrice = 0
  8. let priceHriz = 0;
  9. let priceRoses = 0
  10. let priceTulip = 0;
  11.  
  12. if (season == 'Spring' || season == 'Summer') {
  13. priceHriz = 2.00;
  14. priceRoses = 4.10
  15. priceTulip = 2.50;
  16. totalPrice = boughtHrizantems * priceHriz + boughtRoses * priceRoses + boughtTulips * priceTulip;
  17. if (ifHoliday =='Y') {
  18. totalPrice *= 1.15;
  19. }
  20. if (season == 'Spring' && boughtTulips > 7) {
  21. totalPrice *= 0.95;
  22. }
  23. if (boughtHrizantems + boughtRoses + boughtRoses > 20) {
  24. totalPrice *= 0.80;
  25. }
  26. totalPrice += 2;
  27. } else if (season == 'Autumn' || season == 'Winter') {
  28. priceHriz = 3.75;
  29. priceRoses = 4.50;
  30. priceTulip = 4.15;
  31. totalPrice = boughtHrizantems * priceHriz + boughtRoses * priceRoses + boughtTulips * priceTulip;
  32. if (ifHoliday =='Y') {
  33. totalPrice *= 1.15;
  34. }
  35. if (boughtRoses >= 10 && season == 'Winter') {
  36. totalPrice *= 0.90;
  37. }
  38. if (boughtHrizantems + boughtRoses + boughtRoses > 20) {
  39. totalPrice *= 0.80;
  40. }
  41. totalPrice += 2;
  42. }
  43.  
  44.  
  45. console.log(totalPrice.toFixed(2));
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement