Liliana797979

vacation - fundamentals moeto reshenie

Mar 17th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vacation(people, groupType, day) {
  2.     let price = 0;
  3.     switch (groupType) {
  4.         case "Students":
  5.             switch (day) {
  6.                 case "Friday":
  7.                     price = 8.45;
  8.                     break;
  9.                 case "Saturday":
  10.                     price = 9.80;
  11.                     break;
  12.                 case "Sunday":
  13.                     price = 10.46;
  14.                     break;
  15.             }
  16.            
  17.             break;
  18.  
  19.         case "Business":
  20.         switch (day) {
  21.             case "Friday":
  22.                 price = 10.90;
  23.                 break;
  24.             case "Saturday":
  25.                 price = 15.60;
  26.                 break;
  27.             case "Sunday":
  28.                 price = 16;
  29.                 break;
  30.         }
  31.  
  32.             break;
  33.         case "Regular":
  34.             switch (day) {
  35.                 case "Friday":
  36.                     price = 15;
  37.                     break;
  38.                 case "Saturday":
  39.                     price = 20;
  40.                     break;
  41.                 case "Sunday":
  42.                     price = 22.50;
  43.                     break;
  44.             }
  45.             break;
  46.     }
  47.     let totalPrice = people * price;
  48.     if (groupType === "Students" && people >= 30) {
  49.         price = price * 0.85;
  50.     } else if (groupType === "Business" && people >= 100) {
  51.         totalPrice = totalPrice - 10 * price;
  52.     } else if (groupType === "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