Advertisement
Guest User

Untitled

a guest
Feb 6th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  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 = ( 27.50);
  13. } else if (cabin == "cabin with balcony") {
  14. price = ( 30.20);
  15. } else {
  16. price = ( 40.50);
  17. }
  18.  
  19.  
  20. }
  21. if (cruise == "Adriatic") {
  22. if (cabin == "standard cabin") {
  23. price = ( 22.99);
  24. } else if (cabin == "cabin with balcony") {
  25. price = ( 25.00);
  26. } else if (cabin == "apartment") {
  27. price = (34.99);
  28. }
  29.  
  30. }
  31. if (cruise == "Aegean") {
  32. if (cabin == "standard cabin") {
  33. price = ( 23.00);
  34. } else if (cabin == "cabin with balcony") {
  35. price = ( 26.60);
  36. } else if (cabin == "apartment") {
  37. price = ( 39.80);
  38. }
  39.  
  40. }
  41. let sum = price * nights * 4;
  42.  
  43. if (nights > 7) {
  44. sum *= 0.75;
  45. }
  46.  
  47. console.log(`Annie's holiday in the ${cruise} sea costs ${sum.toFixed(2)} lv.`)
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement