Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vacation(people, groupType, day) {
- let price = 0;
- switch (groupType) {
- case "Students":
- switch (day) {
- case "Friday":
- price = 8.45;
- break;
- case "Saturday":
- price = 9.80;
- break;
- case "Sunday":
- price = 10.46;
- break;
- }
- break;
- case "Business":
- switch (day) {
- case "Friday":
- price = 10.90;
- break;
- case "Saturday":
- price = 15.60;
- break;
- case "Sunday":
- price = 16;
- break;
- }
- break;
- case "Regular":
- switch (day) {
- case "Friday":
- price = 15;
- break;
- case "Saturday":
- price = 20;
- break;
- case "Sunday":
- price = 22.50;
- break;
- }
- break;
- }
- let totalPrice = people * price;
- if (groupType === "Students" && people >= 30) {
- price = price * 0.85;
- } else if (groupType === "Business" && people >= 100) {
- totalPrice = totalPrice - 10 * price;
- } else if (groupType === "Regular" && people >= 10 && people <= 20) {
- totalPrice = totalPrice * 0.95;
- }
- console.log(`Total price: ${totalPrice.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment