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