Advertisement
Guest User

Untitled

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