Ivankooo1

SkiTrip

Jun 2nd, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function SkiTrip(input){
  2.  let days = Number(input.shift());
  3.  let room = input.shift();
  4.  let rating = input.shift();
  5.  let roomForOnePerson = 18.00;
  6.  let apartament = 25.00;
  7.  let presidentRoom = 35.00;
  8.  let Sum = 0;
  9.  let result = 0;
  10.  
  11.  if(room === "apartment"){
  12.     if(days <= 10){
  13.         Sum = (days - 1) * apartament;
  14.         result = Sum - (Sum  * 0.3);
  15.     }
  16.     else if(days <= 15){
  17.         Sum = (days - 1) * apartament;
  18.         result = Sum - (Sum * 0.35);
  19.     }
  20.     else if(days > 15){
  21.         Sum = (days - 1) * apartament;
  22.         result = Sum - (Sum / 2);
  23.     }
  24.  }
  25.  else if(room === 'president apartment'){
  26.      if(days <= 10){
  27.          Sum = (days - 1) * presidentRoom;
  28.          result = Sum - (Sum * 0.1);
  29.      }
  30.      else if(days <= 15){
  31.          Sum = (days - 1) * presidentRoom;
  32.          result = Sum - (Sum * 0.15);
  33.      }
  34.      else if(days > 15){
  35.          Sum = (days - 1) * presidentRoom;
  36.          result = Sum - (Sum * 0.2);
  37.      }
  38.      
  39.  }
  40.  else if(room === "room for one person"){
  41.        result = (days - 1) * roomForOnePerson;
  42.  }
  43.  if(rating === "positive"){
  44.      Sum = result * 1.25;
  45.      console.log(Sum.toFixed(2));
  46.  }
  47.  else if(rating === 'negative'){
  48.      Sum = result * 0.90;
  49.      console.log(Sum.toFixed(2));
  50.  }
  51. }
  52.  
  53. SkiTrip(['14','apartment','positive']);
  54. SkiTrip(['30','president apartment','negative']);
Advertisement
Add Comment
Please, Sign In to add comment