Advertisement
Alexzandur

Ski Trip

Jun 4th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let days = Number(input.shift());
  3.     let room = input.shift();
  4.     let evaluation = input.shift();
  5.  
  6.     let result = 0;
  7.  
  8.     switch (room) {
  9.         case "room for one person": {
  10.             if (evaluation == "positive") {
  11.                 result = ((days - 1) * 18) * 1.25;
  12.             } else if (evaluation == "negative") {
  13.                 result = ((days - 1) * 18) * 0.9;
  14.             }
  15.         }; break;
  16.         case "apartment": {
  17.             if (evaluation == "positive") {
  18.  
  19.                 if (days <= 10) {
  20.                     result = (((days - 1) * 25) * 0.7) * 1.25;
  21.                 } else if (days > 10 && days <= 15) {
  22.                     result = (((days - 1) * 25) * 0.65) * 1.25;
  23.                 } else if (days > 15) {
  24.                     result = (((days - 1) * 25) * 0.5) * 1.25;
  25.                 }
  26.             } else if (evaluation == "negative") {
  27.                 if (days <= 10) {
  28.                     result = (((days - 1) * 25) * 0.7) * 0.9;
  29.                 } else if (days > 10 && days <= 15) {
  30.                     result = (((days - 1) * 25) * 0.65) * 0.9;
  31.                 } else if (days > 15) {
  32.                     result = (((days - 1) * 25) * 0.5) * 0.9;
  33.                 }
  34.             }
  35.         }; break;
  36.         case "president apartment": {
  37.             if (evaluation == "positive") {
  38.  
  39.                 if (days <= 10) {
  40.                     result = (((days - 1) * 35) * 0.9) * 1.25;
  41.                 } else if (days > 10 && days <= 15) {
  42.                     result = (((days - 1) * 35) * 0.85) * 1.25;
  43.                 } else if (days > 15) {
  44.                     result = (((days - 1) * 35) * 0.8) * 1.25;
  45.                 }
  46.             } else if (evaluation == "negative") {
  47.                 if (days <= 10) {
  48.                     result = (((days - 1) * 35) * 0.9) * 0.9;
  49.                 } else if (days > 10 && days <= 15) {
  50.                     result = (((days - 1) * 35) * 0.85) * 0.9;
  51.                 } else if (days > 15) {
  52.                     result = (((days - 1) * 35) * 0.8) * 0.9;
  53.                 }
  54.             }
  55.         }; break;
  56.     }  console.log(`${result.toFixed(2)}`);
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement