mihpolya

Vacation1

Jan 24th, 2019
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. function vacation(count, group, day){
  2. let peopleCount = count;
  3. let peopleClass = group;
  4. let dayOfTheWeek = day;
  5. let pricePerPerson = 0;
  6. let totalPrice = 0;
  7. if(peopleClass === "Students"){
  8. switch(dayOfTheWeek){
  9. case "Fryday":
  10. pricePerPerson = 8.45;
  11. break;
  12. case "Saturday":
  13. pricePerPerson = 9.80;
  14. break;
  15. case "Sunday":
  16. pricePerPerson = 10.46;
  17. break;
  18. }
  19. totalPrice = peopleCount * pricePerPerson;
  20. if (peopleCount >= 30){
  21. totalPrice = totalPrice - totalPrice * 0.15;
  22. }
  23.  
  24. }else if(peopleClass === "Business"){
  25. switch(dayOfTheWeek){
  26. case "Fryday":
  27. pricePerPerson = 10.90;
  28. break;
  29. case "Saturday":
  30. pricePerPerson = 15.60;
  31. break;
  32. case "Sunday":
  33. pricePerPerson = 16;
  34. break;
  35. }
  36. if (peopleCount >= 100){
  37. peopleCount -= 10;
  38. }
  39. totalPrice = peopleCount * pricePerPerson;
  40. } else{
  41. switch(dayOfTheWeek){
  42. case "Fryday":
  43. pricePerPerson = 15;
  44. break;
  45. case "Saturday":
  46. pricePerPerson = 20;
  47. break;
  48. case "Sunday":
  49. pricePerPerson = 22.50;
  50. break;
  51. }
  52. totalPrice = peopleCount * pricePerPerson;
  53. if(peopleCount >= 10 && peopleCount <= 20){
  54. totalPrice -= totalPrice * 0.05;
  55. }
  56.  
  57. }
  58. console.log(`Total price: ${totalPrice.toFixed(2)}`)
  59. }
  60. vacation(54, 'Students', 'Saturday')
Add Comment
Please, Sign In to add comment