Advertisement
bebo231312312321

Untitled

Feb 24th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calculatePrice(month, hoursSpent, groupSize, timeOfDay) {
  2.     let pricePerHour;
  3.     switch (month) {
  4.         case "march":
  5.         case "april":
  6.         case "may":
  7.             pricePerHour = (timeOfDay === "day") ? 10.50 : 8.40;
  8.             break;
  9.         case "june":
  10.         case "july":
  11.         case "august":
  12.             pricePerHour = (timeOfDay === "day") ? 12.60 : 10.20;
  13.             break;
  14.         default:
  15.             return "Invalid month";
  16.     }
  17.  
  18.     if (groupSize >= 4) {
  19.         pricePerHour *= 0.9;
  20.     }
  21.  
  22.     if (hoursSpent >= 5) {
  23.         pricePerHour *= 0.5;
  24.     }
  25.  
  26.     const totalCost = pricePerHour * hoursSpent * groupSize;
  27.     const pricePerPersonPerHour = pricePerHour;
  28.  
  29.     console.log(`Price per person for one hour: ${pricePerPersonPerHour.toFixed(2)}`);
  30.     console.log(`Total cost of the visit: ${totalCost.toFixed(2)}`);
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement