Advertisement
Guest User

Untitled

a guest
Jun 7th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function room(input) {
  2.     let month = String(input.shift());
  3.     let nights = Number(input.shift());
  4.     let discountApr = 0;
  5.     let discountStd = 0;
  6.     let apartCost = 0;
  7.     let studCost = 0;
  8.  
  9.     if (month === "May" || "October") {
  10.         if (nights <= 7 && nights > 0) {
  11.             apartCost = nights * 65
  12.             studCost = nights * 50
  13.             discountApr = apartCost
  14.             discountStd = studCost
  15.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  16.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  17.        
  18.     }
  19.         else if (nights > 7 && nights <= 14) {
  20.             apartCost = nights * 65
  21.             studCost = nights * 50
  22.             discountStd = studCost - ((studCost * 5) / 100)
  23.             discountApr = apartCost
  24.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  25.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  26.         }
  27.  
  28.         else if (nights > 14) {
  29.             apartCost = nights * 65
  30.             studCost = nights * 50
  31.             discountStd = studCost - ((studCost * 30) / 100)
  32.             discountApr = apartCost - ((apartCost * 10) / 100)
  33.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  34.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  35.         }
  36.  
  37.     } else if (month === 'June' || 'September') {
  38.         if (nights > 14) {
  39.             studCost = nights * 75.20
  40.             apartCost = nights * 68.70
  41.             discountStd = studCost - ((studCost * 20) / 100)
  42.             discountApr = apartCost - ((studCost * 10) / 100)
  43.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  44.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  45.         }
  46.  
  47.         else if (nights <= 14 && nights > 0) {
  48.             studCost = nights * 75.20
  49.             apartCost = nights * 68.70
  50.             discountApr = apartCost
  51.             discountStd = studCost
  52.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  53.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  54.         }
  55.     } else if (month === 'July' || 'August') {
  56.         if (nights > 14) {
  57.             studCost = nights * 76
  58.             apartCost = nights * 77
  59.             discountStd = studCost
  60.             discountApr = apartCost - ((studCost * 10) / 100)
  61.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  62.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  63.         }
  64.  
  65.         else if (nights <= 14 && nights > 0) {
  66.             studCost = nights * 76
  67.             apartCost = nights * 77
  68.             discountApr = apartCost
  69.             discountStd = studCost
  70.             console.log(`Apartment: ${discountApr.toFixed(2)} lv.`)
  71.             console.log(`Studio: ${discountStd.toFixed(2)} lv.`)
  72.         }
  73.     }
  74. }
  75. room(['August', 20])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement