Advertisement
Liliana797979

moeto viarno reshenie movie destination

Jan 28th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                function movieDestination(input) {
  2.                     let budget = Number(input[0]);
  3.                     let destination = input[1];
  4.                     let season = input[2];
  5.                     let daysCount = Number(input[3]);
  6.                     let price = 0;
  7.                     let totalPrice = 0;
  8.  
  9.                     switch (season) {
  10.                         case "Winter":
  11.                             switch (destination) {
  12.                                 case "Dubai":
  13.                                     price = 45000;
  14.                                     break;
  15.                                 case "Sofia":
  16.                                     price = 17000;
  17.                                     break;
  18.                                 case "London":
  19.                                     price = 24000;
  20.                                     break;
  21.                             }
  22.                             break;
  23.                         case "Summer":
  24.                             switch (destination) {
  25.                                 case "Dubai":
  26.                                     price = 40000;
  27.                                     break;
  28.                                 case "Sofia":
  29.                                     price = 12500;
  30.                                     break;
  31.                                 case "London":
  32.                                     price = 20250;
  33.                                     break;
  34.                             }
  35.                             break;
  36.                     }
  37.                     if (destination === "Dubai") {
  38.                         price = price * 0.70;
  39.                     } else if (destination === "Sofia") {
  40.                         price = price * 1.25;
  41.                     } else {
  42.                         price = price;
  43.                     }
  44.  
  45.                     totalPrice = daysCount * price;
  46.  
  47.                     if (budget >= totalPrice) {
  48.                         console.log(`The budget for the movie is enough! We have ${(budget - totalPrice).toFixed(2)} leva left!`);
  49.                     } else if (totalPrice > budget) {
  50.                         console.log(`The director needs ${(totalPrice - budget).toFixed(2)} leva more!`);
  51.                     }
  52.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement