vikkktor

hotelRoom

May 30th, 2021 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(input) {
  2.  
  3.     let month = input[0];
  4.     let nightStay = Number(input[1]);
  5.  
  6.     switch (month) {
  7.         case "May":
  8.         case "October":
  9.             priceApartment = 65;
  10.             priceStudio = 50;
  11.             if (nightStay >= 7 && nightStay <= 14) {
  12.                 console.log(`Apartment: ${(nightStay * priceApartment).toFixed(2)} lv.`);
  13.                 console.log(`Studio: ${(nightStay * priceStudio * 0.95).toFixed(2)} lv.`);
  14.             }
  15.             if (nightStay > 14 && nightStay <=200) {
  16.                 console.log(`Apartment: ${(nightStay * priceApartment * 0.90).toFixed(2)} lv.`);
  17.                 console.log(`Studio: ${(nightStay * priceStudio * 0.70).toFixed(2)} lv.`);
  18.             }
  19.             break;
  20.         // -----------------------------------------------------------------------------------
  21.         case "June":
  22.         case "September":
  23.             priceApartment = 68.70;
  24.             priceStudio = 75.20;
  25.             if (nightStay >= 7 && nightStay <= 14) {
  26.                 console.log(`Apartment: ${(nightStay * priceApartment).toFixed(2)} lv.`);
  27.                 console.log(`Studio: ${(nightStay * priceStudio).toFixed(2)} lv.`);
  28.             }
  29.             if (nightStay > 14 && nightStay <=200) {
  30.                 console.log(`Apartment: ${(nightStay * priceApartment * 0.90).toFixed(2)} lv.`);
  31.                 console.log(`Studio: ${(nightStay * priceStudio * 0.80).toFixed(2)} lv.`);
  32.             }
  33.             break;
  34.         // -----------------------------------------------------------------------------------
  35.         case "July":
  36.         case "August":
  37.             priceApartment = 77;
  38.             priceStudio = 76;
  39.             if (nightStay >= 7 && nightStay <= 14) {
  40.                 console.log(`Apartment: ${(nightStay * priceApartment).toFixed(2)} lv.`);
  41.                 console.log(`Studio: ${(nightStay * priceStudio).toFixed(2)} lv.`);
  42.             }
  43.             if (nightStay > 14 && nightStay <=200) {
  44.                 console.log(`Apartment: ${(nightStay * priceApartment * 0.90).toFixed(2)} lv.`);
  45.                 console.log(`Studio: ${(nightStay * priceStudio).toFixed(2)} lv.`);
  46.             }
  47.             break;
  48.     }
  49. }
Add Comment
Please, Sign In to add comment