desito07

Cruise Ship1

May 1st, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. function solve(input) {
  2. let cruise = input.shift();
  3. let cabin = input.shift();
  4. let nightCount = Number(input.shift());
  5. let sum = 0;
  6.  
  7. switch (cruise) {
  8. case "Mediterranean":
  9. if (cabin == "standard cabin") {
  10. sum += nightCount * 27.5 * 4;
  11. } else if (cabin == "cabin with balcony") {
  12. sum += nightCount * 30.2 * 4;
  13. } else if (cabin == "apartment") {
  14. sum += nightCount * 40.5 * 4;
  15. }
  16. break;
  17. case "Adriatic":
  18. if (cabin == "standard cabin") {
  19. sum += nightCount * 22.99 * 4;
  20. } else if (cabin == "cabin with balcony") {
  21. sum += nightCount * 25.0 * 4;
  22. } else if (cabin == "apartment") {
  23. sum += nightCount * 34.99 * 4;
  24. }
  25. break;
  26. case "Aegean":
  27. if (cabin == "standard cabin") {
  28. sum += nightCount * 23.0 * 4;
  29. } else if (cabin == "cabin with balcony") {
  30. sum += nightCount * 26.6 * 4;
  31. } else if (cabin == "apartment") {
  32. sum += nightCount * 39.8 * 4;
  33. }
  34. break;
  35. }
  36. if (nightCount > 7) {
  37. sum -= sum * 0.25;
  38. }
  39. console.log(
  40. `Annie's holiday in the ${cruise} sea costs ${sum.toFixed(2)} lv.`
  41. );
  42. }
Advertisement
Add Comment
Please, Sign In to add comment