Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculatePrice(month, hoursSpent, groupSize, timeOfDay) {
- let pricePerHour;
- switch (month) {
- case "march":
- case "april":
- case "may":
- pricePerHour = (timeOfDay === "day") ? 10.50 : 8.40;
- break;
- case "june":
- case "july":
- case "august":
- pricePerHour = (timeOfDay === "day") ? 12.60 : 10.20;
- break;
- default:
- return "Invalid month";
- }
- if (groupSize >= 4) {
- pricePerHour *= 0.9;
- }
- if (hoursSpent >= 5) {
- pricePerHour *= 0.5;
- }
- const totalCost = pricePerHour * hoursSpent * groupSize;
- const pricePerPersonPerHour = pricePerHour;
- console.log(`Price per person for one hour: ${pricePerPersonPerHour.toFixed(2)}`);
- console.log(`Total cost of the visit: ${totalCost.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement