TZinovieva

School Camp 100/100

May 26th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function schoolCamp(input) {
  2.     let season = input[0];
  3.     let group = input[1];
  4.     let students = Number(input[2]);
  5.     let nights = Number(input[3]);
  6.  
  7.     let price = 0;
  8.     let sport;
  9.  
  10.     if (season === "Winter") {
  11.         if (group === "boys") {
  12.             price = students * nights * 9.60;
  13.             sport = "Judo";
  14.         } else if (group === "girls") {
  15.             price = students * nights * 9.60;
  16.             sport = "Gymnastics";
  17.         } else {
  18.             price = students * nights * 10;
  19.             sport = "Ski";
  20.         }
  21.     } else if (season === "Spring") {
  22.         if (group === "boys") {
  23.             price = students * nights * 7.20;
  24.             sport = "Tennis";
  25.         } else if (group === "girls") {
  26.             price = students * nights * 7.20;
  27.             sport = "Athletics";
  28.         } else {
  29.             price = students * nights * 9.50;
  30.             sport = "Cycling";
  31.         }
  32.     } else {
  33.         if (group === "boys") {
  34.             price = students * nights * 15;
  35.             sport = "Football";
  36.         } else if (group === "girls") {
  37.             price = students * nights * 15;
  38.             sport = "Volleyball";
  39.         } else {
  40.             price = students * nights * 20;
  41.             sport = "Swimming";
  42.         }
  43.     }
  44.     if (students >= 50) {
  45.         price = price * 0.50;
  46.     } else if (students >= 20 && students < 50) {
  47.         price = price * 0.85;
  48.     } else if (students >= 10 && students < 20) {
  49.         price = price * 0.95;
  50.     }
  51.     console.log(`${sport} ${price.toFixed(2)} lv.`);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment