Advertisement
Guest User

Untitled

a guest
Jun 6th, 2020
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cruiseShip(input) {
  2.     let kindOfCruise = input.shift();
  3.     let kindOfCabin = input.shift();
  4.     let numberOfNights = Number(input.shift());
  5.     let standardCabin = 0;
  6.     let cabinWithBalcony = 0;
  7.     let apartment = 0;
  8.     let nightsPrice = 0;
  9.    
  10.     let findPrize = (function(standardPrize,balconPrize,apartmentPrize){
  11.         if (kindOfCabin == "standard cabin") {
  12.             standardCabin = standardPrize;
  13.             nightsPrice = (standardCabin * numberOfNights) * 4;
  14.             if (numberOfNights > 7) {
  15.                 nightsPrice =( (standardCabin * numberOfNights) * 4) * 0.75;
  16.             }
  17.         }else if(kindOfCabin == "cabin with balcony"){
  18.             cabinWithBalcony = balconPrize;
  19.             nightsPrice =( cabinWithBalcony * numberOfNights) * 4;
  20.             if(numberOfNights > 7){
  21.                 nightsPrice = ((cabinWithBalcony * numberOfNights) * 4) * 0.75;
  22.             }
  23.         }else if(kindOfCabin == "apartment"){
  24.             apartment = apartmentPrize;
  25.             nightsPrice = (apartment * numberOfNights) * 4;
  26.             if(numberOfNights > 7){
  27.                 nightsPrice =((apartment * nightsPrice) * 4) * 0.75;
  28.  
  29.             }
  30.         }
  31.     })
  32.     switch (kindOfCruise) {
  33.         case "Mediterranean": findPrize( 27.50, 30.20 ,40.50); break;  
  34.         case "Adriatic": findPrize(22.99,25.00, 34.99); break;
  35.         case "Aegean": findPrize(23.00,26.60,39.80);break;
  36.     }
  37.     console.log(`Annie's holiday in the ${kindOfCruise} sea costs ${nightsPrice.toFixed(2)} lv.`);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement