Advertisement
Spocoman

03. Flowers

Dec 22nd, 2021 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flowers(input) {
  2.  
  3.     let chrysanthemums = parseInt(input[0]);
  4.     let roses = parseInt(input[1]);
  5.     let tulips = parseInt(input[2]);
  6.     let season = input[3];
  7.     let holiday = input[4];
  8.     let sum = 0;
  9.  
  10.     if (season === 'Spring' || season === 'Summer') {
  11.         sum = 2 * chrysanthemums + 4.1 * roses + 2.5 * tulips;
  12.     } else if (season === 'Autumn' || season === 'Winter') {
  13.         sum = 3.75 * chrysanthemums + 4.5 * roses + 4.15 * tulips;
  14.     }
  15.     if (holiday === 'Y') {
  16.         sum = sum * 1.15;
  17.     }
  18.     if (tulips > 7 && season === 'Spring') {
  19.         sum = 0.95 * sum;
  20.     }
  21.     if (roses >= 10 && season === 'Winter') {
  22.         sum = 0.9 * sum;
  23.     }
  24.     if (chrysanthemums + roses + tulips > 20) {
  25.         sum = 0.8 * sum;
  26.     }
  27.     console.log(`${(sum + 2).toFixed(2)}`);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement