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