Liliana797979

vacation - fundamentals

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