TZinovieva

Fitness Card

Jan 3rd, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fitnessCard(input) {
  2.     let budget = Number(input[0]);
  3.     let gender = input[1];
  4.     let age = Number(input[2]);
  5.     let sport = input[3];
  6.  
  7.     let cardPrice = 0;
  8.     switch (gender) {
  9.         case 'm':
  10.             if (sport === "Gym") {
  11.                 cardPrice = 42;
  12.             } else if (sport === "Boxing") {
  13.                 cardPrice = 41;
  14.             } else if (sport === "Yoga") {
  15.                 cardPrice = 45;
  16.             } else if (sport === "Zumba") {
  17.                 cardPrice = 34;
  18.             } else if (sport === "Dances") {
  19.                 cardPrice = 51;
  20.             } else if (sport === "Pilates") {
  21.                 cardPrice = 39;
  22.             }
  23.             break;
  24.         case 'f':
  25.             if (sport === "Gym") {
  26.                 cardPrice = 35;
  27.             } else if (sport === "Boxing") {
  28.                 cardPrice = 37;
  29.             } else if (sport === "Yoga") {
  30.                 cardPrice = 42;
  31.             } else if (sport === "Zumba") {
  32.                 cardPrice = 31;
  33.             } else if (sport === "Dances") {
  34.                 cardPrice = 53;
  35.             } else if (sport === "Pilates") {
  36.                 cardPrice = 37;
  37.             }
  38.             break;
  39.     }
  40.     if (age <= 19) {
  41.         cardPrice -= cardPrice * 0.20;
  42.     }
  43.     if (budget >= cardPrice) {
  44.         console.log(`You purchased a 1 month pass for ${sport}.`);
  45.     } else {
  46.         console.log(`You don't have enough money! You need $${(cardPrice - budget).toFixed(2)} more.`);
  47.    }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment