Advertisement
vborislavova

03.CompRoom - final_exam_29.02.2020

Mar 28th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function prices(input) {
  2.     let month = input.shift();
  3.     let hoursPlayed = Number(input.shift());
  4.     let people = Number(input.shift());
  5.     let daytime = input.shift();
  6.     let price = 0;
  7.  
  8.     if (month === "march" || month === "april" || month === "may") {
  9.         if (daytime === "day") {
  10.             price = 10.5;
  11.         } else {
  12.             price = 8.4;
  13.         }
  14.  
  15.     } else if ((month === "june" || month === "july" || month === "august")) {
  16.         if (daytime === "day") {
  17.             price = 12.6;
  18.         } else {
  19.             price = 10.2;
  20.         }
  21.     }
  22.  
  23.     if (people >= 4) {
  24.         price *= 0.9;
  25.     }
  26.  
  27.     if (hoursPlayed >= 5) {
  28.         price *= 0.5;
  29.     }
  30.  
  31.     console.log(`Price per person for one hour: ${price.toFixed(2)}`);
  32.     console.log(`Total cost of the visit: ${((hoursPlayed * price) * people).toFixed(2)}`);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement