Advertisement
v_zapryanov

09. Ski Trip

May 20th, 2022
790
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 kindOfRoom = input[1];
  4.     let rate = input[2];
  5.  
  6.     let cost = 0;
  7.  
  8.     switch(kindOfRoom) {
  9.         case 'room for one person':
  10.             cost = (days - 1) * 18.00;
  11.             break;
  12.  
  13.         case 'apartment':
  14.             cost = (days - 1) * 25.00;
  15.             if (days < 10) {
  16.                 cost = cost * 0.7;
  17.             } else if (days >= 10 && days <= 15) {
  18.                 cost = cost * 0.65;
  19.             } else {
  20.                 cost = cost * 0.50;
  21.             } break;
  22.  
  23.         case 'president apartment':
  24.             cost = (days - 1) * 35.00;
  25.             if (days < 10) {
  26.                 cost = cost * 0.9;
  27.             } else if (days >= 10 && days <= 15) {
  28.                 cost = cost * 0.85;
  29.             } else {
  30.                 cost = cost * 0.80;
  31.             } break;
  32.     }
  33.  
  34.     if (rate === 'positive') {
  35.         cost = cost * 1.25;
  36.     } else {
  37.         cost = cost * 0.90;
  38.     }
  39.  
  40.     console.log(cost.toFixed(2));
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement