Ledger Nano X - The secure hardware wallet
SHARE
TWEET

nested exercise

Elpida3006 Apr 10th, 2020 163 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(month, night) {
  2. month = month;
  3. night = +(night);
  4.  
  5. let studio = 0;
  6. let apartment = 0;
  7.  
  8. switch (month) {
  9.     case  "May": studio = 50; apartment = 65; break;
  10.     case "October": studio = 50; apartment = 65; break;
  11.     case "June": studio = 75.20; apartment = 68.70; break;
  12.     case "September": studio = 75.20; apartment = 68.70; break;
  13.     case "July": studio = 76; apartment = 77; break;
  14.     case "August": studio = 76; apartment = 77; break;
  15.  
  16. }
  17.  
  18. if ((night > 14) && (month == "May" || month == "October")) {
  19.     studio *= 0.70;
  20. }
  21. if ((night > 14) && (month == "June" || month == "September")) {
  22.     studio *= 0.80;  
  23. }
  24. if ((night > 7 && night <= 14) && (month == "May" || month == "October")) {
  25.     studio *= 0.95;
  26. }
  27. if (night > 14) {
  28.     apartment *= 0.90;
  29. }
  30. let priceStudio = (night * studio).toFixed(2);
  31. let priceApartment = (night * apartment).toFixed(2);
  32.  
  33. console.log(`Apartment: ${priceApartment} lv.`)
  34. console.log(`Studio: ${priceStudio} lv.`)
  35.  
  36. }
  37. hotelRoom("May", 15);
  38. hotelRoom("June", 14);
  39. hotelRoom("August", 20);
  40.  
  41.  
  42.  
  43. function onTimeForExam(hourExam, minExam, hourSchool, minSchool) {
  44.  
  45.  
  46. hourExam = +(hourExam);
  47. minExam = +(minExam);
  48. hourSchool = +(hourSchool);
  49. minSchool = +(minSchool);
  50.  
  51.  
  52. let examInMins = hourExam * 60 + minExam;
  53. let arrivalMins = hourSchool * 60 + minSchool;
  54. let diff = examInMins - arrivalMins;
  55.  
  56. if (diff < 0) {
  57.     console.log("Late");
  58.     if (diff > -60) {
  59.         console.log(`${Math.abs(diff)} minutes after the start`);
  60.     }
  61.         else {
  62.          
  63.             let hours = (Math.floor(Math.abs(diff) / 60));
  64.             let min = Math.abs(diff % 60);
  65.             if (min < 10) {
  66.                 console.log(`${hours}:0${min} hours after the start`);
  67.                 }
  68.                 else {
  69.                     console.log(`${hours}:${min} hours after the start`);
  70.                 }
  71.         }
  72.     }
  73.  
  74.  
  75.                     else if (diff <= 30) {
  76.                              console.log("On Time");
  77.                              if (diff > 0) {
  78.                                
  79.                                 console.log(`${diff} minutes before the start`);
  80.                              }
  81.                             }
  82. else
  83. {
  84.     console.log("Early");
  85.  
  86.     if (diff < 60) {
  87.     console.log(`${diff} minutes before the start`);
  88.     }
  89.     else  
  90.     {
  91.         let hours = Math.floor(diff / 60);
  92.         let min = diff % 60;
  93.         if (min < 10) {
  94.         console.log(`${hours}:0${min} hours before the start`);
  95.         }
  96.         else {
  97.             console.log(`${hours}:${min} hours before the start`);
  98.         }
  99.     }
  100. }
  101.  
  102.  
  103.  
  104. }
  105. onTimeForExam(9, 30, 10, 50);
  106. onTimeForExam(9, 00, 8, 30);
  107. onTimeForExam(16, 00, 15, 00);
  108. onTimeForExam(9, 00, 9, 00);
  109.  
  110.  
  111.  
  112. function volleyball(year, p, h) {
  113. year = (year);
  114. p = +(p);
  115. h = +(h);
  116.  
  117.  
  118.  
  119. let weekend = 48;
  120. let sofiaWeekendDay = (48 - h) * 3 / 4;
  121. let townWeekendDay = h ;
  122. let playHoliday = (p * 2) / 3;
  123. let playWeekend = sofiaWeekendDay + townWeekendDay;
  124.  
  125. if (year === "leap") {
  126.  playHoliday *= 1.15;
  127.  playWeekend *= 1.15;
  128.  
  129. }
  130.  
  131. console.log(Math.floor(playHoliday + playWeekend));
  132.  
  133. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top