TZinovieva

Ski Trip 100/100

May 24th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function skiTrip(input) {
  2.     let days = Number(input[0]);
  3.     let roomType = input[1];
  4.     let rating = input [2];
  5.  
  6.     let nights = days - 1;
  7.     let price = 0;
  8.  
  9.     switch (roomType) {
  10.         case "room for one person":
  11.             price = nights * 18; break;
  12.         case "apartment":
  13.             price = nights * 25;
  14.             if (nights < 10) {
  15.                 price = price * 0.70;
  16.             } else if (nights >= 10 && nights < 15) {
  17.                 price = price * 0.65;
  18.             } else {
  19.                 price = price * 0.50;
  20.             }
  21.             break;
  22.         case "president apartment":
  23.             price = nights * 35;
  24.             if (nights < 10) {
  25.                 price = price * 0.90;
  26.             } else if (nights >= 10 && nights < 15) {
  27.                 price = price * 0.85;
  28.             } else {
  29.                 price = price * 0.80;
  30.             }
  31.             break;
  32.     }
  33.     if (rating === "positive") {
  34.         price = price * 1.25;
  35.     } else {
  36.         price = price * 0.90;
  37.     }
  38.     console.log(price.toFixed(2));
  39. }
Advertisement
Add Comment
Please, Sign In to add comment