Advertisement
Liliana797979

excursion calculator

Nov 28th, 2020
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function excurzionCalculator(arg1, arg2) {
  3. let season = arg1;
  4. let people = Number(arg2);
  5. let price = 0;
  6. let percent = 0;
  7. let totalPrice = 0;
  8. let totalSum = 0;
  9.  
  10. switch(season) {  
  11.     case "spring":
  12.         break;
  13.     case "summer":  
  14.         break;
  15.     case "autumn":
  16.         break;
  17.     case "winter":
  18.         break;
  19.  
  20.  
  21.     if (people <= 5 && season == "spring") {
  22.     price = 50;
  23.     }
  24.  if  (people > 5 && season == "spring") {
  25. price = 48;
  26. }
  27.         if (people <= 5 && season == "summer") {
  28.             price = 48.50;
  29.         }
  30.         if (people > 5 && season == "summer") }
  31.         price = 45;
  32.     }
  33.                 if (people <= 5 && season == "autumn") {
  34.                     price = 60;
  35.                 }
  36.                 if (people > 5 && season == "autumn") {
  37.                     price = 49.50;
  38.                 }
  39.                         if (people <= 5 && season == "winter") {
  40.                             price = 86;              
  41.         }
  42.         if (people > 5 && season == "winter") {
  43.             price = 85;
  44.         }
  45.    
  46.         totalPrice = price * people;
  47.         if (season == "summer") {
  48.             totalSum = totalPrice * 0.85;
  49.         } else if (season == "winter") {
  50.             totalSum = totalPrice * 0.08;
  51.  
  52.         console.log(`${totalSum.toFixed(2)} leva.`);
  53.  
  54.     }
  55. }
  56.  
  57. }
  58.  
  59.  
  60. excurzionCalculator(5,"spring");  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement