Advertisement
Guest User

Untitled

a guest
May 22nd, 2020
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(days, roomType, experience) {
  2.   days = Number(days);
  3.   let nights = days - 1;
  4.   let price = 0;
  5.  
  6.   if (roomType === 'room for one person') {
  7.     price = 18 * nights;
  8.   } else if (roomType === 'apartment' && days < 10) {
  9.     price = 25 * nights * 0.7;
  10.   } else if (roomType === 'apartment' && days >= 10 && days <= 15) {
  11.     price = 25 * nights * 0.65;
  12.   } else if (roomType === 'apartment' && days > 15) {
  13.     price = 25 * nights * 0.5;
  14.   } else if (roomType === 'president apartment' && days < 10) {
  15.     price = 35 * nights * 0.9;
  16.   } else if (roomType === 'president apartment' && days >= 10 && days <= 15) {
  17.     price = 35 * nights * 0.85;
  18.   } else if (roomType === 'president apartment' && days > 15) {
  19.     price = 35 * nights * 0.8;
  20.   }
  21.  
  22.   if (experience === 'positive') {
  23.     price += 0.25 * price;
  24.   } else if (experience === 'negative') {
  25.     price -= 0.1 * price;
  26.   }
  27.   console.log(price.toFixed(2));
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement