ProdanTenev

Hotel room

Feb 16th, 2022 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.60 KB | None | 0 0
  1. function hotelRoom(input) {
  2.     let month = input[0];   // May, June, July, August, September или October
  3.     let count_nights = Number(input[1]);
  4.     let priceForStudio;
  5.     let priceForApartment;
  6.     let studioPerNight;
  7.     let apartmentPerNight;
  8.     if (month == "May" || month == "October") {
  9.         studioPerNight = 50;
  10.         apartmentPerNight = 65;
  11.         priceForApartment = apartmentPerNight * count_nights;
  12.         if (count_nights > 7 && count_nights < 14) {
  13.             priceForStudio = (studioPerNight * count_nights) * 0.95;
  14.         } else if (count_nights > 14) {
  15.             priceForStudio = (studioPerNight * count_nights) * 0.70;
  16.         } else {
  17.             priceForStudio = studioPerNight * count_nights;
  18.         }
  19.     } else if (month == "June" || month == "September") {
  20.         studioPerNight = 75.20;
  21.         apartmentPerNight = 68.70;
  22.         priceForApartment = apartmentPerNight * count_nights;
  23.         if (count_nights > 14) {
  24.             priceForStudio = (studioPerNight * count_nights) * 0.80;
  25.         } else {
  26.             priceForStudio = studioPerNight * count_nights;
  27.         }
  28.     } else if (month == "July" || month == "August") {
  29.         studioPerNight = 76;
  30.         apartmentPerNight = 77;
  31.         priceForStudio = studioPerNight * count_nights;
  32.         priceForApartment = apartmentPerNight * count_nights;
  33.     }
  34.     if (count_nights > 14) {
  35.         priceForApartment *= 0.9;
  36.     } else {
  37.         priceForApartment *= 1;
  38.     }
  39.     console.log(`Apartment: ${priceForApartment.toFixed(2)} lv.`);
  40.     console.log(`Studio: ${priceForStudio.toFixed(2)} lv.`);
  41. }
Add Comment
Please, Sign In to add comment