Advertisement
vprichkapova

Vacation

May 24th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. function vacation(people, typeOfGroup, dayOfWeek) {
  2. let price = 0;
  3. let totalPrice = 0;
  4.  
  5. if (dayOfWeek == "Friday") {
  6. switch (typeOfGroup) {
  7. case "Students":
  8. price = 8.45;
  9. break;
  10. case "Business":
  11. price = 10.9;
  12. break;
  13. case "Regular":
  14. price = 15;
  15. break;
  16. }
  17. } else if (dayOfWeek == "Saturday") {
  18. switch (typeOfGroup) {
  19. case "Students":
  20. price = 9.8;
  21. break;
  22. case "Business":
  23. price = 15.6;
  24. break;
  25. case "Regular":
  26. price = 20;
  27. break;
  28. }
  29. } else if (dayOfWeek == "Sunday") {
  30. switch (typeOfGroup) {
  31. case "Students":
  32. price = 10.46;
  33. break;
  34. case "Business":
  35. price = 16;
  36. break;
  37. case "Regular":
  38. price = 22.5;
  39. break;
  40. }
  41. }
  42.  
  43. if (typeOfGroup === "Students" && people >= 30) {
  44. totalPrice = people * price * 0.85;
  45. } else if (typeOfGroup === "Business" && people >= 100) {
  46. totalPrice = (people - 10) * price;
  47. } else if (people >= 10 && people <= 20) {
  48. totalPrice = people * price * 0.95;
  49. } else {
  50. totalPrice = people * price;
  51. }
  52.  
  53. console.log(`Total price: ${totalPrice.toFixed(2)}`);
  54. }
  55.  
  56. vacation(30, "Students", "Sunday");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement