Advertisement
Guest User

CruiseShip

a guest
Feb 26th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let cruise = input.shift();
  3.     let cabin = input.shift();
  4.     let nights = Number(input.shift());
  5.     let price = 0;
  6.     switch (cruise) {
  7.         case 'Mediterranean':
  8.             switch (cabin) {
  9.                 case 'standard cabin':
  10.                     price = nights * 27.5;
  11.                     break;
  12.                 case 'cabin with balcony':
  13.                     price = nights * 30.2;
  14.                     break;
  15.                 case 'apartment':
  16.                     price = nights * 40.5;
  17.                     break;
  18.             }
  19.             break;
  20.         case 'Adriatic':
  21.             switch (cabin) {
  22.                 case 'standard cabin':
  23.                     price = nights * 22.99;
  24.                     break;
  25.                 case 'cabin with balcony':
  26.                     price = nights * 25;
  27.                     break;
  28.                 case 'apartment':
  29.                     price = nights * 34.99;
  30.                     break;
  31.             }
  32.             break;
  33.         case 'Aegean':
  34.             switch (cabin) {
  35.                 case 'standard cabin':
  36.                     price = nights * 23.0;
  37.                     break;
  38.                 case 'cabin with balcony':
  39.                     price = nights * 26.6;
  40.                     break;
  41.                 case 'apartment':
  42.                     price = nights * 39.8;
  43.                     break;
  44.             }
  45.             break;
  46.     }
  47.     if (nights > 7) {
  48.         price = price * 0.75;
  49.     }
  50.     console.log(`Annie's holiday in the ${cruise} sea costs ${(price * 4).toFixed(2)} lv.`);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement