Advertisement
AlexandrP

07. Hotel Room - 80/100

Nov 18th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function room(input) {
  2.  
  3.     let month = input[0];
  4.     let nights = Number(input[1]);
  5.     let priceS;
  6.     let priceA;
  7.  
  8.     switch (month) {
  9.         case "May":
  10.         case "October":
  11.             priceS = 50;
  12.             priceA = 65;
  13.             if (nights > 7 && nights <= 14) {
  14.                 priceS = priceS * 0.95;
  15.             } else if (nights > 14) {
  16.                 priceS = priceS * 0.7;
  17.                 priceA = priceA * 0.9;
  18.  
  19.             }
  20.             break;
  21.  
  22.         case "June":
  23.         case "September ":
  24.             priceS = 75.20;
  25.             priceA = 68.70;
  26.             if (nights > 14) {
  27.                 priceS = priceS * 0.8;
  28.                 priceA = priceA * 0.9;
  29.             }
  30.             break;
  31.  
  32.         case "July":
  33.         case "August":
  34.             priceS = 76;
  35.             priceA = 77;
  36.  
  37.             if (nights > 14) {
  38.                 priceA = priceA * 0.9;
  39.        
  40.             }
  41.  
  42.             break;
  43.     }
  44.    
  45.    
  46.    
  47.  
  48.     let sumA = priceA * nights;
  49.     let sumS= priceS * nights;
  50.  
  51.  
  52.  
  53.  
  54.  
  55.     console.log(`Apartment: ${sumA.toFixed(2)} lv.`);
  56.     console.log(`Studio: ${sumS.toFixed(2)} lv.`);
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement