Advertisement
nevenailievaa

09. Ski Trip

Mar 16th, 2025
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calculateHotelPrice(days, roomType, feedback) {
  2.     let nights = days - 1;
  3.     let pricePerNight = 0;
  4.  
  5.     if (roomType === "room for one person") {
  6.         pricePerNight = 18.00;
  7.     } else if (roomType === "apartment") {
  8.         pricePerNight = 25.00;
  9.         if (nights < 10) {
  10.             pricePerNight *= 0.70;
  11.         } else if (nights <= 15) {
  12.             pricePerNight *= 0.65;
  13.         } else {
  14.             pricePerNight *= 0.50;
  15.         }
  16.     } else if (roomType === "president apartment") {
  17.         pricePerNight = 35.00;
  18.         if (nights < 10) {
  19.             pricePerNight *= 0.90;
  20.         } else if (nights <= 15) {
  21.             pricePerNight *= 0.85;
  22.         } else {
  23.             pricePerNight *= 0.80;
  24.         }
  25.     }
  26.  
  27.     let totalPrice = nights * pricePerNight;
  28.    
  29.     if (feedback === "positive") {
  30.         totalPrice *= 1.25;
  31.     } else if (feedback === "negative") {
  32.         totalPrice *= 0.90;
  33.     }
  34.  
  35.     console.log(totalPrice.toFixed(2));
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement