Advertisement
Spocoman

Computer Room

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